public static IEnumerable <IRawStreamEntry> WithPayloadTypes <T1, T2>(this IEnumerable <IRawStreamEntry> entries, ISerializationBinder binder = null)
        {
            binder = binder ?? new VersionedBinder();

            var allNames = new[] {
                binder.BindToName(typeof(T1)),
                binder.BindToName(typeof(T2))
            };

            return(entries.Where(x => allNames.Contains(x.PayloadType)));
        }
Beispiel #2
0
        /// <summary>
        /// Taken from Newtonsoft.Json
        /// </summary>
        /// <param name="t"></param>
        /// <param name="assemblyFormat"></param>
        /// <param name="binder"></param>
        /// <returns></returns>
        public static string GetTypeName(Type t, FormatterAssemblyStyle assemblyFormat, ISerializationBinder binder)
        {
            string fullyQualifiedTypeName;

            if (binder != null)
            {
                binder.BindToName(t, out string assemblyName, out string typeName);
                fullyQualifiedTypeName = typeName + (assemblyName == null ? "" : ", " + assemblyName);
            }
            else
            {
                fullyQualifiedTypeName = t.AssemblyQualifiedName;
            }
            switch (assemblyFormat)
            {
            case FormatterAssemblyStyle.Simple:
                return(RemoveAssemblyDetails(fullyQualifiedTypeName));

            case FormatterAssemblyStyle.Full:
                return(fullyQualifiedTypeName);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public void BindToName(Type serializedType, out string assemblyName, out string typeName)
 {
     binder.BindToName(serializedType, out assemblyName, out typeName);
     if (typeName != null && typeName.StartsWith(namespaceToRemove))
     {
         typeName = typeName.Substring(namespaceToRemove.Length);
     }
     assemblyName = null;
 }
Beispiel #4
0
 // Token: 0x06000E1F RID: 3615 RVA: 0x00051968 File Offset: 0x0004FB68
 private static string GetFullyQualifiedTypeName(Type t, [Nullable(2)] ISerializationBinder binder)
 {
     if (binder != null)
     {
         string text;
         string str;
         binder.BindToName(t, out text, out str);
         return(str + ((text == null) ? "" : (", " + text)));
     }
     return(t.AssemblyQualifiedName);
 }
Beispiel #5
0
        public string GetTypeName(Type objectType)
        {
            serializationBinder.BindToName(objectType, out _, out var typeName);

            if (typeName == null || typeName == objectType.FullName)
            {
                typeName = objectType.Name;
            }

            return(typeName);
        }
        private static string GetFullyQualifiedTypeName(Type t, ISerializationBinder binder)
        {
            if (binder != null)
            {
                string assemblyName;
                string typeName;
                binder.BindToName(t, out assemblyName, out typeName);
                return(typeName + (assemblyName == null ? "" : ", " + assemblyName));
            }

            return(t.AssemblyQualifiedName);
        }
Beispiel #7
0
        public void BindToName(Type serializedType, out string assemblyName, out string typeName)
        {
            binder.BindToName(serializedType, out assemblyName, out typeName);

            if (typeName != null)
            {
                typeName = typeName.Replace("WCA.GlobalX.Client", "GlobalX.Common.DataModel", StringComparison.InvariantCultureIgnoreCase);
            }

            if (assemblyName != null)
            {
                assemblyName = "GlobalX.CDM.Common";
            }
        }
Beispiel #8
0
        private static string GetFullyQualifiedTypeName(Type t, ISerializationBinder binder)
        {
            if (binder != null)
            {
                binder.BindToName(t, out string assemblyName, out string typeName);
#if (NET20 || NET35)
                // for older SerializationBinder implementations that didn't have BindToName
                if (assemblyName == null & typeName == null)
                {
                    return(t.AssemblyQualifiedName);
                }
#endif
                return(typeName + (assemblyName == null ? "" : ", " + assemblyName));
            }

            return(t.AssemblyQualifiedName);
        }
            public void BindToName(Type serializedType, out string assemblyName, out string typeName)
            {
                if (serializedType == typeof(CreatedEvent))
                {
                    typeName     = "Created";
                    assemblyName = null;
                    return;
                }
                if (serializedType == typeof(EditedEvent))
                {
                    typeName     = "Edited";
                    assemblyName = null;
                    return;
                }

                fallback.BindToName(serializedType, out assemblyName, out typeName);
            }
Beispiel #10
0
 public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
 {
     if (serializedType.FullName.StartsWith("<>f__AnonymousType") || serializedType.Name.Equals("ExpandoObject"))
     // It's either a dynamic type as a result of projection or an
     // anonymous type perhaps constructed by a controller (e.g, a "Lookups" object)
     //
     // These two predicates would work for dynamic types but not anonymous types
     // if (serializedType.Assembly.IsDynamic)
     // if (serializedType.BaseType == typeof(Breeze.ContextProvider.DynamicTypeBase))
     {
         assemblyName = "Dynamic";
         typeName     = serializedType.Name;
     }
     else
     {
         _binder.BindToName(serializedType, out assemblyName, out typeName);
     }
 }
Beispiel #11
0
 public void BindToName(Type serializedType, out string assemblyName, out string typeName)
 {
     binder.BindToName(serializedType, out assemblyName, out typeName);
 }
Beispiel #12
0
 /// <inheritdoc />
 public virtual void BindToName(Type serializedType, out string assemblyName, out string typeName) =>
 innerBinder.BindToName(serializedType, out assemblyName, out typeName);
        public static IEnumerable <IRawStreamEntry> WithPayloadType <T>(this IEnumerable <IRawStreamEntry> entries, ISerializationBinder binder = null)
        {
            binder = binder ?? new VersionedBinder();

            return(entries.Where(x => x.PayloadType == binder.BindToName(typeof(T))));
        }