Exemple #1
0
        public JsonDictionaryContract(Type underlyingType) : base(underlyingType)
        {
            Type type;
            Type type2;

            base.enum15_0 = Enum15.Dictionary;
            if (Class194.smethod_14(underlyingType, typeof(IDictionary <,>), out this.type_3))
            {
                type  = this.type_3.GetGenericArguments()[0];
                type2 = this.type_3.GetGenericArguments()[1];
                if (Class194.smethod_12(base.UnderlyingType, typeof(IDictionary <,>)))
                {
                    base.CreatedType = typeof(Dictionary <,>).MakeGenericType(new Type[] { type, type2 });
                }
            }
            else
            {
                Class194.smethod_19(base.UnderlyingType, out type, out type2);
                if (base.UnderlyingType == typeof(IDictionary))
                {
                    base.CreatedType = typeof(Dictionary <object, object>);
                }
            }
            if ((type != null) && (type2 != null))
            {
                this.ConstructorInfo_0 = Class191.smethod_3(base.CreatedType, typeof(KeyValuePair <,>).MakeGenericType(new Type[] { type, type2 }));
            }
            this.Boolean_0           = !typeof(IDictionary).IsAssignableFrom(base.CreatedType);
            this.DictionaryKeyType   = type;
            this.DictionaryValueType = type2;
            if (this.DictionaryValueType != null)
            {
                this.bool_7 = Class194.smethod_10(this.DictionaryValueType);
            }
        }
    public int method_0(Paragraph A_0, Regex A_1, string A_2)
    {
        int num = 0x12;
        ParagraphItemCollection items = A_0.Items;
        string          text          = A_0.Text;
        MatchCollection matchs        = A_1.Matches(text);

        if (matchs.Count > 0)
        {
            int num2   = 0;
            int num3   = 0;
            int length = A_2.Length;
            int num5   = 0;
            int num6   = 0;
            foreach (Match match in matchs)
            {
                ParagraphBase base2;
                num5 = match.Index + num2;
                num6 = match.Length;
                num3 = length - match.Length;
                A_0.method_66(num5, num6, A_2);
                TextRange entity = null;
                int       num9   = Class191.smethod_3(A_0, num5 + 1, out base2);
                if (base2 is TextRange)
                {
                    entity = base2 as TextRange;
                }
                else if (base2 is Break)
                {
                    entity = (base2 as Break).TextRange;
                }
                int num8 = entity.StartPos + entity.TextLength;
                entity.SafeText = false;
                if (num8 > (num5 + num6))
                {
                    entity.TextLength += num3;
                }
                else
                {
                    ParagraphBase base3;
                    this.method_5(A_0, num5 + num6, num9 + 1, out base3);
                    int num10 = num5 + num6;
                    if (base3 is TextRange)
                    {
                        TextRange range2 = base3 as TextRange;
                        range2.TextLength -= num10 - range2.StartPos;
                        range2.StartPos    = num10 + num3;
                        num9++;
                    }
                    entity.TextLength = (num10 + num3) - entity.StartPos;
                }
                this.method_6(A_0, num9 + 1, num3);
                num2 += num3;
                if (base2 is Break)
                {
                    int       index  = A_0.ChildObjects.IndexOf(base2);
                    TextRange range3 = new TextRange(entity.Document)
                    {
                        StartPos   = base2.StartPos,
                        TextLength = A_2.Length
                    };
                    range3.CharacterFormat.ApplyBase(base2.CharacterFormat.method_23());
                    A_0.ChildObjects.InnerList.RemoveAt(index);
                    A_0.ChildObjects.InnerList.Insert(index, range3);
                    range3.method_0(A_0);
                    entity = range3;
                }
                else if (((entity != null) && (entity.DocumentObjectType == DocumentObjectType.TextRange)) && (entity.Text == BookmarkStart.b("㌷", num)))
                {
                    int   num11  = A_0.ChildObjects.IndexOf(entity);
                    Break @break = new Break(entity.Document)
                    {
                        StartPos = entity.StartPos
                    };
                    A_0.ChildObjects.InnerList.RemoveAt(num11);
                    A_0.ChildObjects.InnerList.Insert(num11, @break);
                    @break.method_0(A_0);
                }
                if (entity != null)
                {
                    entity.method_39();
                }
                if (A_0.Document.ReplaceFirst)
                {
                    break;
                }
            }
        }
        int count = matchs.Count;

        if (A_0.Document.ReplaceFirst && (count > 0))
        {
            return(count);
        }
        return(count + smethod_1(A_0, A_1, A_2));
    }
Exemple #3
0
        public JsonArrayContract(Type underlyingType) : base(underlyingType)
        {
            bool flag;

            base.enum15_0 = Enum15.Array;
            if (base.CreatedType.IsArray)
            {
                this.CollectionItemType = Class194.smethod_18(base.UnderlyingType);
                base.bool_4             = true;
                this.type_3             = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType });
                flag = true;
                this.IsMultidimensionalArray = base.UnderlyingType.IsArray && (base.UnderlyingType.GetArrayRank() > 1);
            }
            else if (typeof(IList).IsAssignableFrom(underlyingType))
            {
                if (Class194.smethod_14(underlyingType, typeof(ICollection <>), out this.type_3))
                {
                    this.CollectionItemType = this.type_3.GetGenericArguments()[0];
                }
                else
                {
                    this.CollectionItemType = Class194.smethod_18(underlyingType);
                }
                if (underlyingType == typeof(IList))
                {
                    base.CreatedType = typeof(List <object>);
                }
                if (this.CollectionItemType != null)
                {
                    this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType);
                }
                base.bool_4 = Class194.smethod_15(underlyingType, typeof(ReadOnlyCollection <>));
                flag        = true;
            }
            else if (Class194.smethod_14(underlyingType, typeof(ICollection <>), out this.type_3))
            {
                this.CollectionItemType = this.type_3.GetGenericArguments()[0];
                if (Class194.smethod_12(underlyingType, typeof(ICollection <>)) || Class194.smethod_12(underlyingType, typeof(IList <>)))
                {
                    base.CreatedType = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType });
                }
                if (Class194.smethod_12(underlyingType, typeof(ISet <>)))
                {
                    base.CreatedType = typeof(HashSet <>).MakeGenericType(new Type[] { this.CollectionItemType });
                }
                this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType);
                flag           = true;
                this.Boolean_0 = true;
            }
            else
            {
                Type type;
                if (Class194.smethod_14(underlyingType, typeof(IEnumerable <>), out type))
                {
                    this.CollectionItemType = type.GetGenericArguments()[0];
                    if (Class194.smethod_12(base.UnderlyingType, typeof(IEnumerable <>)))
                    {
                        base.CreatedType = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType });
                    }
                    this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType);
                    if (underlyingType.smethod_4() && (underlyingType.GetGenericTypeDefinition() == typeof(IEnumerable <>)))
                    {
                        this.type_3    = type;
                        base.bool_4    = false;
                        this.Boolean_0 = false;
                        flag           = true;
                    }
                    else
                    {
                        this.type_3    = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType });
                        base.bool_4    = true;
                        this.Boolean_0 = true;
                        flag           = this.ConstructorInfo_0 != null;
                    }
                }
                else
                {
                    flag           = false;
                    this.Boolean_0 = true;
                }
            }
            this.Boolean_1 = flag;
            if (this.CollectionItemType != null)
            {
                this.bool_7 = Class194.smethod_10(this.CollectionItemType);
            }
        }