Ejemplo n.º 1
0
Archivo: Meta.cs Proyecto: mrojkov/Yuzu
        private void AddMethod(MethodInfo m)
        {
            var attrs = Options.GetItem(m);

            if (attrs.HasAttr(Options.SerializeItemIfAttribute))
            {
                if (SerializeItemIf != null)
                {
                    throw Error("Duplicate SerializeItemIf");
                }
                if (Utils.GetIEnumerable(Type) == null)
                {
                    throw Error("SerializeItemIf may only be used inside of IEnumerable");
                }
                SerializeItemIf       = Options.GetSerializeItemCondition(m);
                SerializeItemIfMethod = m;
            }
            BeforeSerialization.MaybeAdd(m, Options.BeforeSerializationAttribute);
            AfterSerialization.MaybeAdd(m, Options.AfterSerializationAttribute);
            BeforeDeserialization.MaybeAdd(m, Options.BeforeDeserializationAttribute);
            AfterDeserialization.MaybeAdd(m, Options.AfterDeserializationAttribute);

            if (attrs.HasAttr(Options.FactoryAttribute))
            {
                if (FactoryMethod != null)
                {
                    throw Error("Duplicate Factory: '{0}' and '{1}'", FactoryMethod.Name, m.Name);
                }
                if (!m.IsStatic || m.GetParameters().Length > 0)
                {
                    throw Error("Factory '{0}' must be a static method without parameters", m.Name);
                }
                FactoryMethod = m;
                Factory       = (Func <object>)Delegate.CreateDelegate(typeof(Func <object>), m);
            }

            Surrogate.ProcessMethod(m);
        }
Ejemplo n.º 2
0
 private void AddMethod(MethodInfo m)
 {
     BeforeSerialization.MaybeAdd(m, Options.BeforeSerializationAttribute);
     AfterDeserialization.MaybeAdd(m, Options.AfterDeserializationAttribute);
     Surrogate.ProcessMethod(m);
 }