예제 #1
0
 private static void CheckObjectMode(Type type, ref WellKnownObjectModeEnum targetMode, ref bool foundFlag)
 {
     if (type.GetInterfaces().Length > 0)
     {
         foreach (Type interfaceClass in type.GetInterfaces())
         {
             ServiceContractAttribute scAnnotation = TypeHelper.GetAttribute <ServiceContractAttribute>(interfaceClass);
             if (scAnnotation != null)
             {
                 // van attribútum
                 if (!foundFlag)
                 {
                     // meg van az első WellKnownObjectMode, ez lesz a referencia a többi számára
                     targetMode = scAnnotation.WellKnownObjectMode;
                     foundFlag  = true;
                 }
                 else if (!targetMode.Equals(scAnnotation.WellKnownObjectMode))
                 {
                     // eltérő
                     throw new InvalidProxyImplementationException(String.Format("Different {0} definitions found on type '{1}'. Contract '{2}' configured to '{3}' and previously found '{4}' mode.", typeof(WellKnownObjectModeEnum).FullName, type.FullName, interfaceClass.FullName, scAnnotation.WellKnownObjectMode, targetMode.ToString()));
                 }
             }
             if (!foundFlag)
             {
                 // még nincs referencia WellKnownObjectMode
                 CheckObjectMode(interfaceClass, ref targetMode, ref foundFlag);
             }
             else
             {
                 // már van
                 WellKnownObjectModeEnum interfaceMode = WellKnownObjectModeEnum.PerSession;
                 bool tempFound = false;
                 CheckObjectMode(interfaceClass, ref interfaceMode, ref tempFound);
                 if (tempFound && foundFlag && !targetMode.Equals(interfaceMode))
                 {
                     // eltérő
                     throw new InvalidProxyImplementationException(String.Format("Different {0} definitions found on type '{1}'. Contract '{2}' configured to '{3}' and previously found '{4}' mode.", typeof(WellKnownObjectModeEnum).FullName, type.FullName, interfaceClass.FullName, interfaceMode.ToString(), targetMode.ToString()));
                 }
                 if (tempFound && !foundFlag)
                 {
                     // meg van az első WellKnownObjectMode, referencia mentése
                     targetMode = interfaceMode;
                     foundFlag  = true;
                 }
             }
         }
     }
     if (type.BaseType != null && !type.BaseType.Equals(typeof(ProxyBase)) && !type.BaseType.Equals(typeof(Object)))
     {
         CheckObjectMode(type.BaseType, ref targetMode, ref foundFlag);
     }
 }