// Token: 0x060002D9 RID: 729 RVA: 0x0000FEAC File Offset: 0x0000E0AC internal bool Contains(object value) { BasicList.NodeEnumerator enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { if (object.Equals(enumerator.Current, value)) { return(true); } } return(false); }
internal MetaType FindWithoutAdd(Type type) { BasicList.NodeEnumerator enumerator = this.types.GetEnumerator(); while (enumerator.MoveNext()) { MetaType metaType = (MetaType)enumerator.Current; if (metaType.Type == type) { if (metaType.Pending) { this.WaitOnLock(metaType); } return(metaType); } } Type type2 = TypeModel.ResolveProxies(type); return((type2 != null) ? this.FindWithoutAdd(type2) : null); }
public override string GetSchema(Type type) { BasicList basicList = new BasicList(); MetaType metaType = null; bool flag = false; if (type == null) { BasicList.NodeEnumerator enumerator = this.types.GetEnumerator(); while (enumerator.MoveNext()) { MetaType metaType2 = (MetaType)enumerator.Current; MetaType surrogateOrBaseOrSelf = metaType2.GetSurrogateOrBaseOrSelf(false); if (!basicList.Contains(surrogateOrBaseOrSelf)) { basicList.Add(surrogateOrBaseOrSelf); this.CascadeDependents(basicList, surrogateOrBaseOrSelf); } } } else { Type underlyingType = Helpers.GetUnderlyingType(type); if (underlyingType != null) { type = underlyingType; } WireType wireType; flag = (ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type, out wireType, false, false, false, false) != null); if (!flag) { int num = this.FindOrAddAuto(type, false, false, false); if (num < 0) { throw new ArgumentException("The type specified is not a contract-type", "type"); } metaType = ((MetaType)this.types[num]).GetSurrogateOrBaseOrSelf(false); basicList.Add(metaType); this.CascadeDependents(basicList, metaType); } } StringBuilder stringBuilder = new StringBuilder(); string text = null; if (!flag) { IEnumerable enumerable = (metaType != null) ? basicList : this.types; IEnumerator enumerator2 = enumerable.GetEnumerator(); try { while (enumerator2.MoveNext()) { MetaType metaType3 = (MetaType)enumerator2.get_Current(); if (!metaType3.IsList) { string @namespace = metaType3.Type.get_Namespace(); if (!Helpers.IsNullOrEmpty(@namespace)) { if ([email protected]("System.")) { if (text == null) { text = @namespace; } else if (!(text == @namespace)) { text = null; break; } } } } } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } if (!Helpers.IsNullOrEmpty(text)) { stringBuilder.Append("package ").Append(text).Append(';'); Helpers.AppendLine(stringBuilder); } bool flag2 = false; StringBuilder stringBuilder2 = new StringBuilder(); MetaType[] array = new MetaType[basicList.Count]; basicList.CopyTo(array, 0); Array.Sort <MetaType>(array, MetaType.Comparer.Default); if (flag) { Helpers.AppendLine(stringBuilder2).Append("message ").Append(type.get_Name()).Append(" {"); MetaType.NewLine(stringBuilder2, 1).Append("optional ").Append(this.GetSchemaTypeName(type, DataFormat.Default, false, false, ref flag2)).Append(" value = 1;"); Helpers.AppendLine(stringBuilder2).Append('}'); } else { for (int i = 0; i < array.Length; i++) { MetaType metaType4 = array[i]; if (!metaType4.IsList || metaType4 == metaType) { metaType4.WriteSchema(stringBuilder2, 0, ref flag2); } } } if (flag2) { stringBuilder.Append("import \"bcl.proto\"; // schema for protobuf-net's handling of core .NET types"); Helpers.AppendLine(stringBuilder); } return(Helpers.AppendLine(stringBuilder.Append(stringBuilder2)).ToString()); }
public override string GetSchema(Type type) { BasicList basicList = new BasicList(); MetaType metaType = null; bool flag = false; if (type == null) { BasicList.NodeEnumerator enumerator = types.GetEnumerator(); while (enumerator.MoveNext()) { MetaType surrogateOrBaseOrSelf = ((MetaType)enumerator.Current).GetSurrogateOrBaseOrSelf(deep: false); if (!basicList.Contains(surrogateOrBaseOrSelf)) { basicList.Add(surrogateOrBaseOrSelf); CascadeDependents(basicList, surrogateOrBaseOrSelf); } } } else { Type underlyingType = Helpers.GetUnderlyingType(type); if (underlyingType != null) { type = underlyingType; } flag = (ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type, out WireType _, asReference: false, dynamicType: false, overwriteList: false, allowComplexTypes: false) != null); if (!flag) { int num = FindOrAddAuto(type, demand: false, addWithContractOnly: false, addEvenIfAutoDisabled: false); if (num < 0) { throw new ArgumentException("The type specified is not a contract-type", "type"); } metaType = ((MetaType)types[num]).GetSurrogateOrBaseOrSelf(deep: false); basicList.Add(metaType); CascadeDependents(basicList, metaType); } } StringBuilder stringBuilder = new StringBuilder(); string text = null; if (!flag) { foreach (MetaType item in (IEnumerable)((metaType == null) ? types : basicList)) { if (!item.IsList) { string @namespace = item.Type.Namespace; if (!Helpers.IsNullOrEmpty(@namespace) && [email protected]("System.")) { if (text == null) { text = @namespace; } else if (!(text == @namespace)) { text = null; break; } } } } } if (!Helpers.IsNullOrEmpty(text)) { stringBuilder.Append("package ").Append(text).Append(';'); Helpers.AppendLine(stringBuilder); } bool requiresBclImport = false; StringBuilder stringBuilder2 = new StringBuilder(); MetaType[] array = new MetaType[basicList.Count]; basicList.CopyTo(array, 0); Array.Sort(array, MetaType.Comparer.Default); if (flag) { Helpers.AppendLine(stringBuilder2).Append("message ").Append(type.Name) .Append(" {"); MetaType.NewLine(stringBuilder2, 1).Append("optional ").Append(GetSchemaTypeName(type, DataFormat.Default, asReference: false, dynamicType: false, ref requiresBclImport)) .Append(" value = 1;"); Helpers.AppendLine(stringBuilder2).Append('}'); } else { foreach (MetaType metaType3 in array) { if (!metaType3.IsList || metaType3 == metaType) { metaType3.WriteSchema(stringBuilder2, 0, ref requiresBclImport); } } } if (requiresBclImport) { stringBuilder.Append("import \"bcl.proto\"; // schema for protobuf-net's handling of core .NET types"); Helpers.AppendLine(stringBuilder); } return(Helpers.AppendLine(stringBuilder.Append(stringBuilder2)).ToString()); }