123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- #if !NO_GENERICS
- using System.Collections.Generic;
- #endif
- using ProtoBuf.Meta;
- using System.Collections;
- namespace ProtoBuf
- {
-
-
-
-
-
-
-
-
-
-
- public abstract class Extensible : IExtensible
- {
-
-
- private IExtension extensionObject;
- IExtension IExtensible.GetExtensionObject(bool createIfMissing)
- {
- return GetExtensionObject(createIfMissing);
- }
-
-
-
-
-
-
-
-
-
-
- protected virtual IExtension GetExtensionObject(bool createIfMissing)
- {
- return GetExtensionObject(ref extensionObject, createIfMissing);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public static IExtension GetExtensionObject(ref IExtension extensionObject, bool createIfMissing)
- {
- if (createIfMissing && extensionObject == null)
- {
- extensionObject = new BufferExtension();
- }
- return extensionObject;
- }
- #if !NO_RUNTIME && !NO_GENERICS
-
-
-
-
-
-
-
-
-
-
-
-
- public static void AppendValue<TValue>(IExtensible instance, int tag, TValue value)
- {
- AppendValue<TValue>(instance, tag, DataFormat.Default, value);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static void AppendValue<TValue>(IExtensible instance, int tag, DataFormat format, TValue value)
- {
- ExtensibleUtil.AppendExtendValue(RuntimeTypeModel.Default, instance, tag, format, value);
- }
-
-
-
-
-
-
-
-
-
- public static TValue GetValue<TValue>(IExtensible instance, int tag)
- {
- return GetValue<TValue>(instance, tag, DataFormat.Default);
- }
-
-
-
-
-
-
-
-
-
-
- public static TValue GetValue<TValue>(IExtensible instance, int tag, DataFormat format)
- {
- TValue value;
- TryGetValue<TValue>(instance, tag, format, out value);
- return value;
- }
-
-
-
-
-
-
-
-
-
-
- public static bool TryGetValue<TValue>(IExtensible instance, int tag, out TValue value)
- {
- return TryGetValue<TValue>(instance, tag, DataFormat.Default, out value);
- }
-
-
-
-
-
-
-
-
-
-
-
- public static bool TryGetValue<TValue>(IExtensible instance, int tag, DataFormat format, out TValue value)
- {
- return TryGetValue<TValue>(instance, tag, format, false, out value);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public static bool TryGetValue<TValue>(IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out TValue value)
- {
- value = default(TValue);
- bool set = false;
- foreach (TValue val in ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, format, true, allowDefinedTag))
- {
-
-
- value = val;
- set = true;
- }
- return set;
- }
-
-
-
-
-
-
-
-
-
-
- public static IEnumerable<TValue> GetValues<TValue>(IExtensible instance, int tag)
- {
- return ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, DataFormat.Default, false, false);
- }
-
-
-
-
-
-
-
-
-
-
-
- public static IEnumerable<TValue> GetValues<TValue>(IExtensible instance, int tag, DataFormat format)
- {
- return ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, format, false, false);
- }
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static bool TryGetValue(TypeModel model, System.Type type, IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out object value)
- {
- value = null;
- bool set = false;
- foreach (object val in ExtensibleUtil.GetExtendedValues(model, type, instance, tag, format, true, allowDefinedTag))
- {
-
-
- value = val;
- set = true;
- }
- return set;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public static IEnumerable GetValues(TypeModel model, System.Type type, IExtensible instance, int tag, DataFormat format)
- {
- return ExtensibleUtil.GetExtendedValues(model, type, instance, tag, format, false, false);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static void AppendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value)
- {
- ExtensibleUtil.AppendExtendValue(model, instance, tag, format, value);
- }
-
- }
- }
|