public DefaultExpressionManager(Net.Vpc.Upa.PersistenceUnit persistenceUnit) { this.persistenceUnit = persistenceUnit; translationManager = new Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager(this, persistenceUnit); validationManager = new Net.Vpc.Upa.Impl.Uql.ExpressionValidationManager(persistenceUnit); expressionMetadataBuilder = new Net.Vpc.Upa.Impl.Uql.ExpressionMetadataBuilder(this, persistenceUnit); parser = persistenceUnit.GetFactory().CreateObject <Net.Vpc.Upa.QLExpressionParser>(typeof(Net.Vpc.Upa.QLExpressionParser)); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateTypeTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.DataTypeTransformConfig transformConfig) { if (transformConfig == null) { return(null); } if (transformConfig is Net.Vpc.Upa.Types.DataTypeTransform) { return((Net.Vpc.Upa.Types.DataTypeTransform)transformConfig); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform)) { Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform c = (Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform)transformConfig; return(CreateTypeTransform(pu, source, CreateDataTypeTransformConfigArray(c.GetExpression()))); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomTypeDataTypeTransform)) { Net.Vpc.Upa.Types.CustomTypeDataTypeTransform c = (Net.Vpc.Upa.Types.CustomTypeDataTypeTransform)transformConfig; return(pu.GetFactory().CreateObject <T>(c.GetCustomType())); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform)) { Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform c = (Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform)transformConfig; Net.Vpc.Upa.Types.DataTypeTransform i = c.GetInstance(); return(i); } else if (transformConfig is Net.Vpc.Upa.PasswordTransformConfig) { Net.Vpc.Upa.PasswordTransformConfig p = (Net.Vpc.Upa.PasswordTransformConfig)transformConfig; return(CreatePasswordTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.SecretTransformConfig) { Net.Vpc.Upa.Types.SecretTransformConfig p = (Net.Vpc.Upa.Types.SecretTransformConfig)transformConfig; return(CreateSecretTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.StringEncoderTransformConfig) { Net.Vpc.Upa.Types.StringEncoderTransformConfig p = (Net.Vpc.Upa.Types.StringEncoderTransformConfig)transformConfig; return(CreateStringEncoderTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig) { Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig p = (Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig)transformConfig; return(CreateByteArrayEncoderTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig) { Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig p = (Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig)transformConfig; return(CreateCharArrayEncoderTransform(pu, source, p)); } throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported Transform Method", source); }
public EntityDescriptorResolver(Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Impl.Config.Decorations.DecorationRepository decorationRepository) { this.persistenceUnit = persistenceUnit; this.decorationRepository = decorationRepository; this.annotationParser = new Net.Vpc.Upa.Impl.Config.Annotationparser.DecorationEntityDescriptorResolver(decorationRepository, persistenceUnit.GetFactory()); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateCharArrayEncoderTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig(); } Net.Vpc.Upa.Types.CharArrayEncoder preEncoder = null; int baseSize = 0; if (source is Net.Vpc.Upa.Types.IntType) { preEncoder = Net.Vpc.Upa.Impl.Transform.IntToStringCharArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.LongType) { preEncoder = Net.Vpc.Upa.Impl.Transform.LongToStringCharArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.DoubleType) { preEncoder = Net.Vpc.Upa.Impl.Transform.DoubleToStringCharArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.FloatType) { preEncoder = Net.Vpc.Upa.Impl.Transform.FloatToStringCharArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.StringType) { preEncoder = Net.Vpc.Upa.Impl.Transform.StringToCharArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.ByteArrayType) { preEncoder = null; baseSize = 255; } else { throw new System.ArgumentException("Unsupported"); } object postEncoderObject = p.GetEncoder(); Net.Vpc.Upa.Types.CharArrayEncoder postEncoder = null; if (postEncoderObject == null) { } else if (postEncoderObject is string) { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty((string)postEncoderObject)) { postEncoder = pu.GetFactory().CreateObject <T>((string)postEncoderObject); } } else if (postEncoderObject is System.Type) { postEncoder = (Net.Vpc.Upa.Types.CharArrayEncoder)pu.GetFactory().CreateObject <object>((System.Type)postEncoderObject); } else if (postEncoderObject is Net.Vpc.Upa.Types.ByteArrayEncoder) { postEncoder = (Net.Vpc.Upa.Types.CharArrayEncoder)postEncoderObject; } else { throw new System.ArgumentException("Unsupported"); } if (p.GetSize() <= 0) { p.SetSize(baseSize); } Net.Vpc.Upa.Types.CharArrayEncoder finalEncoder = null; if (preEncoder == null) { finalEncoder = postEncoder; } else if (postEncoder == null) { finalEncoder = preEncoder; } else { finalEncoder = new Net.Vpc.Upa.Impl.Transform.ChainCharArrayEncoder(preEncoder, postEncoder); } if (finalEncoder == null) { finalEncoder = Net.Vpc.Upa.Impl.Transform.IdentityCharArrayEncoder.INSTANCE; } return(new Net.Vpc.Upa.Impl.Transform.CharArrayEncoderDataTypeTransform(finalEncoder, source, p.GetSize())); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateByteArrayEncoderTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig(); } int baseSize = 0; Net.Vpc.Upa.Types.ByteArrayEncoder enc = null; if (source is Net.Vpc.Upa.Types.IntType) { enc = Net.Vpc.Upa.Impl.Transform.IntToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.LongType) { enc = Net.Vpc.Upa.Impl.Transform.LongToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.DoubleType) { enc = Net.Vpc.Upa.Impl.Transform.DoubleToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.FloatType) { enc = Net.Vpc.Upa.Impl.Transform.FloatToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.StringType) { enc = Net.Vpc.Upa.Impl.Transform.StringToByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.ByteArrayType) { enc = null; baseSize = 255; Net.Vpc.Upa.Types.EnumType et = (Net.Vpc.Upa.Types.EnumType)source; enc = new Net.Vpc.Upa.Impl.Transform.EnumToStringByteArrayEncoder(source.GetPlatformType()); //should we baseSize = 3; foreach (object @value in et.GetValues()) { if (@value != null) { int cs = (System.Convert.ToString(@value)).Length; if (cs > baseSize) { baseSize = cs; } } } } else { throw new System.ArgumentException("Unsupported"); } object postEncoderObject = p.GetEncoder(); Net.Vpc.Upa.Types.ByteArrayEncoder postEncoder = null; if (postEncoderObject == null) { } else if (postEncoderObject is string) { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty((string)postEncoderObject)) { postEncoder = pu.GetFactory().CreateObject <T>((string)postEncoderObject); } } else if (postEncoderObject is System.Type) { postEncoder = (Net.Vpc.Upa.Types.ByteArrayEncoder)pu.GetFactory().CreateObject <object>((System.Type)postEncoderObject); } else if (postEncoderObject is Net.Vpc.Upa.Types.ByteArrayEncoder) { postEncoder = (Net.Vpc.Upa.Types.ByteArrayEncoder)postEncoderObject; } else { throw new System.ArgumentException("Unsupported"); } if (p.GetSize() <= 0) { p.SetSize(baseSize); } Net.Vpc.Upa.Types.ByteArrayEncoder finalEncoder = null; if (enc == null) { finalEncoder = postEncoder; } else if (postEncoder == null) { finalEncoder = enc; } else { finalEncoder = new Net.Vpc.Upa.Impl.Transform.ChainByteArrayEncoder(enc, postEncoder); } if (finalEncoder == null) { finalEncoder = Net.Vpc.Upa.Impl.Transform.IdentityByteArrayEncoder.INSTANCE; } return(new Net.Vpc.Upa.Impl.Transform.ByteArrayEncoderDataTypeTransform(finalEncoder, source, p.GetSize())); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateStringEncoderTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.StringEncoderTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.StringEncoderTransformConfig(); } Net.Vpc.Upa.Types.ByteArrayEncoder toStringEncoder = null; int baseSize = 0; object encoderObject = p.GetEncoder(); if (encoderObject == null) { encoderObject = Net.Vpc.Upa.Config.StringEncoderType.DEFAULT; } if (source is Net.Vpc.Upa.Types.IntType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.IntToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.LongType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.LongToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.DoubleType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.DoubleToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.FloatType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.FloatToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.ByteArrayType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.IdentityByteArrayEncoder.INSTANCE; baseSize = ((Net.Vpc.Upa.Types.ByteArrayType)source).GetMaxSize() == null ? ((int)(0)) : (((Net.Vpc.Upa.Types.ByteArrayType)source).GetMaxSize()).Value; if (encoderObject == Net.Vpc.Upa.Config.StringEncoderType.DEFAULT) { encoderObject = Net.Vpc.Upa.Config.StringEncoderType.HEXADECIMAL; } } else if (source is Net.Vpc.Upa.Types.EnumType) { Net.Vpc.Upa.Types.EnumType et = (Net.Vpc.Upa.Types.EnumType)source; toStringEncoder = new Net.Vpc.Upa.Impl.Transform.EnumToStringByteArrayEncoder(source.GetPlatformType()); //should we baseSize = 3; foreach (object @value in et.GetValues()) { if (@value != null) { int cs = (System.Convert.ToString(@value)).Length; if (cs > baseSize) { baseSize = cs; } } } } else { throw new System.ArgumentException("Unsupported"); } if (baseSize <= 0) { baseSize = 255; } Net.Vpc.Upa.Types.StringEncoder encoder = null; if (encoderObject is Net.Vpc.Upa.Config.StringEncoderType) { Net.Vpc.Upa.Config.StringEncoderType set = (Net.Vpc.Upa.Config.StringEncoderType)encoderObject; if (set == Net.Vpc.Upa.Config.StringEncoderType.DEFAULT) { set = Net.Vpc.Upa.Config.StringEncoderType.PLAIN; } if (set == Net.Vpc.Upa.Config.StringEncoderType.CUSTOM) { throw new System.ArgumentException("Unsupported"); } switch (set) { case Net.Vpc.Upa.Config.StringEncoderType.BASE64: { encoder = Net.Vpc.Upa.Impl.Transform.Base64Encoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize * 4 / 3 + 2); } break; } case Net.Vpc.Upa.Config.StringEncoderType.HEXADECIMAL: { encoder = Net.Vpc.Upa.Impl.Transform.HexaEncoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize * 2); } break; } case Net.Vpc.Upa.Config.StringEncoderType.PLAIN: { encoder = Net.Vpc.Upa.Impl.Transform.PlainStringEncoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize); } break; } case Net.Vpc.Upa.Config.StringEncoderType.XML: { if (p.GetSize() <= 0) { p.SetSize(baseSize); } throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } case Net.Vpc.Upa.Config.StringEncoderType.JSON: { if (p.GetSize() <= 0) { p.SetSize(baseSize); } throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } default: { throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } } } else if (encoderObject is string) { return(pu.GetFactory().CreateObject <T>((string)encoderObject)); } else if (encoderObject is System.Type) { return((Net.Vpc.Upa.Types.DataTypeTransform)pu.GetFactory().CreateObject <object>((System.Type)encoderObject)); } else { throw new System.ArgumentException("Unsupported Encoder " + encoderObject); } return(new Net.Vpc.Upa.Impl.Transform.StringEncoderDataTypeTransform(encoder, source, p.GetSize(), toStringEncoder)); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateSecretTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.SecretTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.SecretTransformConfig(); } object s = p.GetSecretStrategy(); if (s == null) { s = Net.Vpc.Upa.SecretStrategyType.DEFAULT; } if (s is Net.Vpc.Upa.SecretStrategyType) { switch (((Net.Vpc.Upa.SecretStrategyType)s)) { case Net.Vpc.Upa.SecretStrategyType.BASE64: { s = Net.Vpc.Upa.Impl.Transform.Base64SecretStrategy.INSTANCE; break; } case Net.Vpc.Upa.SecretStrategyType.DEFAULT: { s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); break; } default: { throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported", s); } } } else if (s is string) { string ss = (string)s; if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(ss)) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <T>((string)s); } else { //use default s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); } } else if (s is System.Type) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <object>((System.Type)s); } else if (s is Net.Vpc.Upa.SecretStrategy) { s = (Net.Vpc.Upa.SecretStrategy)s; } else { throw new System.ArgumentException("Unsupported SecretStrategy " + s); } Net.Vpc.Upa.SecretStrategy st = (Net.Vpc.Upa.SecretStrategy)s; st.Init(pu, p.GetEncodeKey(), p.GetDecodeKey()); p.SetSecretStrategy(st); if (!(source is Net.Vpc.Upa.Types.ByteArrayType)) { Net.Vpc.Upa.Types.DataTypeTransform t = null; t = CreateByteArrayEncoderTransform(pu, source, null); Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform t2 = new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, t.GetTargetType(), p.GetSize()); return(t.Chain(t2)); } return(new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, source, p.GetSize())); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreatePasswordTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.PasswordTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.PasswordTransformConfig(); } object s = p.GetCipherStrategy(); if (s == null) { s = Net.Vpc.Upa.PasswordStrategyType.DEFAULT; } if (s is Net.Vpc.Upa.PasswordStrategyType) { switch (((Net.Vpc.Upa.PasswordStrategyType)s)) { case Net.Vpc.Upa.PasswordStrategyType.SHA1: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.SHA1; break; } case Net.Vpc.Upa.PasswordStrategyType.SHA256: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.SHA256; break; } case Net.Vpc.Upa.PasswordStrategyType.MD5: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; break; } case Net.Vpc.Upa.PasswordStrategyType.DEFAULT: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; break; } default: { throw new System.ArgumentException("Unsupported CipherStrategy " + s); } } } else if (s is string) { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty((string)s)) { s = (Net.Vpc.Upa.PasswordStrategy)pu.GetFactory().CreateObject <T>((string)s); } else { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; } } else if (s is System.Type) { s = (Net.Vpc.Upa.PasswordStrategy)pu.GetFactory().CreateObject <object>((System.Type)s); } else if (s is Net.Vpc.Upa.PasswordStrategy) { s = (Net.Vpc.Upa.PasswordStrategy)s; } else { throw new System.ArgumentException("Unsupported CipherStrategy " + s); } p.SetCipherStrategy((Net.Vpc.Upa.PasswordStrategy)s); Net.Vpc.Upa.Types.DataTypeTransform t = null; object cipherValue = p.GetCipherValue(); if (!(source is Net.Vpc.Upa.Types.StringType)) { t = CreateStringEncoderTransform(pu, source, null); Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform t2 = new Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform((Net.Vpc.Upa.PasswordStrategy)p.GetCipherStrategy(), cipherValue, t.GetTargetType()); return(t.Chain(t2)); } return(new Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform((Net.Vpc.Upa.PasswordStrategy)p.GetCipherStrategy(), cipherValue, source)); }
public virtual void PersistenceUnitItemScanned(Net.Vpc.Upa.ScanEvent @event) { if (listener != null) { listener.PersistenceUnitItemScanned(@event); } Net.Vpc.Upa.PersistenceUnit persistenceUnit = @event.GetPersistenceUnit(); System.Type contract = @event.GetContract(); System.Type type = @event.GetVisitedType(); if (Net.Vpc.Upa.Impl.Config.URLAnnotationStrategySupport.IsPersistenceUnitItemDefinitionListener(contract)) { object i = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type); if (i == null) { i = persistenceUnit.GetFactory().CreateObject <object>(type); instances[type] = i; } Net.Vpc.Upa.Config.Decoration at = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject(); string _filter = at.GetString("filter"); bool _trackSystemObjects = at.GetBoolean("trackSystemObjects"); // Callback cb = (Callback) at.getAnnotation(); if ((_filter).Length == 0) { persistenceUnit.AddDefinitionListener((Net.Vpc.Upa.Callbacks.DefinitionListener)i, _trackSystemObjects); } else { persistenceUnit.AddDefinitionListener(_filter, (Net.Vpc.Upa.Callbacks.DefinitionListener)i, _trackSystemObjects); } } else if (typeof(Net.Vpc.Upa.Callbacks.PersistenceUnitListener).Equals(contract)) { object i = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type); if (i == null) { i = persistenceUnit.GetFactory().CreateObject <object>(type); instances[type] = i; } persistenceUnit.AddPersistenceUnitListener((Net.Vpc.Upa.Callbacks.PersistenceUnitListener)i); } else if (typeof(Net.Vpc.Upa.Callbacks.EntityInterceptor).Equals(contract)) { Net.Vpc.Upa.Callbacks.EntityInterceptor i = (Net.Vpc.Upa.Callbacks.EntityInterceptor)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type); if (i == null) { try { i = (Net.Vpc.Upa.Callbacks.EntityInterceptor)persistenceUnit.GetFactory().CreateObject <object>(type); } catch (System.Exception ex) { log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(null, ex)); } if (i != null) { instances[type] = i; } } if (i != null) { Net.Vpc.Upa.Config.Decoration at = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject(); string _filter = at.GetString("filter"); string _name = at.GetString("name"); if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(_name)) { _name = (i.GetType()).Name; } bool _trackSystemObjects = at.GetBoolean("trackSystemObjects"); // Callback cb = (Callback) at.getAnnotation(); persistenceUnit.AddTrigger(_name, i, _filter, _trackSystemObjects); } } else if (typeof(Net.Vpc.Upa.EntityDescriptor).Equals(@event.GetContract())) { Net.Vpc.Upa.EntityDescriptor desc = (Net.Vpc.Upa.EntityDescriptor)@event.GetUserObject(); persistenceUnit.AddEntity(desc); } else if (typeof(Net.Vpc.Upa.Function).Equals(@event.GetContract())) { Net.Vpc.Upa.Function f = (Net.Vpc.Upa.Function)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType()); Net.Vpc.Upa.Config.Decoration d = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject(); // net.vpc.upa.config.FunctionDefinition d = type.getAnnotation(); Net.Vpc.Upa.Types.DataType dt = Net.Vpc.Upa.Types.TypesFactory.ForPlatformType(d.GetType("returnType")); string n = d.GetString("name"); if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(n)) { n = d.GetLocationType(); } persistenceUnit.GetExpressionManager().AddFunction(n, dt, f); } else if (typeof(Net.Vpc.Upa.Callback).Equals(@event.GetContract())) { Net.Vpc.Upa.Callback callbackType = (Net.Vpc.Upa.Callback)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType()); persistenceUnit.AddCallback(callbackType); } else if (typeof(Net.Vpc.Upa.EntitySecurityManager).Equals(@event.GetContract())) { Net.Vpc.Upa.Config.Decoration d = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject(); Net.Vpc.Upa.EntitySecurityManager secu = (Net.Vpc.Upa.EntitySecurityManager)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType()); Net.Vpc.Upa.Impl.Config.EntityConfiguratorProcessor.ConfigureOneShot(persistenceUnit, new Net.Vpc.Upa.Impl.Util.SimpleEntityFilter(new Net.Vpc.Upa.Impl.Util.EqualsStringFilter(d.GetString("entity"), false, false), true), new Net.Vpc.Upa.Impl.Config.SecurityManagerEntityConfigurator(secu)); } else if (@event.GetUserObject() is Net.Vpc.Upa.Impl.Config.DecoratedMethodScan) { Net.Vpc.Upa.Impl.Config.DecoratedMethodScan dms = (Net.Vpc.Upa.Impl.Config.DecoratedMethodScan)@event.GetUserObject(); Net.Vpc.Upa.Config.Decoration callbackDecoration = dms.GetDecoration(); ConfigureMethodCallback(type, dms.GetMethod(), callbackDecoration, persistenceUnit); } }
public static void ConfigureMethodCallback(System.Type type, System.Reflection.MethodInfo method, Net.Vpc.Upa.Config.Decoration methodDecoration, Net.Vpc.Upa.PersistenceUnit persistenceUnit) { Net.Vpc.Upa.CallbackType callbackType = Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.CallbackType>(typeof(Net.Vpc.Upa.CallbackType)); Net.Vpc.Upa.EventPhase callbackPhase = Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.EventPhase>(typeof(Net.Vpc.Upa.EventPhase)); System.Collections.Generic.IDictionary <string, object> conf = new System.Collections.Generic.Dictionary <string, object>(); if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreAlter))) { callbackType = Net.Vpc.Upa.CallbackType.ON_ALTER; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnAlter))) { callbackType = Net.Vpc.Upa.CallbackType.ON_ALTER; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreCreate))) { callbackType = Net.Vpc.Upa.CallbackType.ON_CREATE; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnCreate))) { callbackType = Net.Vpc.Upa.CallbackType.ON_CREATE; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreDrop))) { callbackType = Net.Vpc.Upa.CallbackType.ON_DROP; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnDrop))) { callbackType = Net.Vpc.Upa.CallbackType.ON_DROP; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPrePersist))) { callbackType = Net.Vpc.Upa.CallbackType.ON_PERSIST; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPersist))) { callbackType = Net.Vpc.Upa.CallbackType.ON_PERSIST; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreUpdate))) { callbackType = Net.Vpc.Upa.CallbackType.ON_UPDATE; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnUpdate))) { callbackType = Net.Vpc.Upa.CallbackType.ON_UPDATE; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreRemove))) { callbackType = Net.Vpc.Upa.CallbackType.ON_REMOVE; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnRemove))) { callbackType = Net.Vpc.Upa.CallbackType.ON_REMOVE; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreReset))) { callbackType = Net.Vpc.Upa.CallbackType.ON_RESET; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnReset))) { callbackType = Net.Vpc.Upa.CallbackType.ON_RESET; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreInitialize))) { callbackType = Net.Vpc.Upa.CallbackType.ON_INITIALIZE; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnInitialize))) { callbackType = Net.Vpc.Upa.CallbackType.ON_INITIALIZE; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnPreUpdateFormula))) { callbackType = Net.Vpc.Upa.CallbackType.ON_UPDATE_FORMULAS; callbackPhase = Net.Vpc.Upa.EventPhase.BEFORE; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.OnUpdateFormula))) { callbackType = Net.Vpc.Upa.CallbackType.ON_UPDATE_FORMULAS; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; conf["trackSystemObjects"] = methodDecoration.GetBoolean("trackSystemObjects"); } else if (methodDecoration.IsName(typeof(Net.Vpc.Upa.Config.Function))) { callbackType = Net.Vpc.Upa.CallbackType.ON_EVAL; callbackPhase = Net.Vpc.Upa.EventPhase.AFTER; string functionName = methodDecoration.GetString("name"); System.Type returnType = methodDecoration.GetType("returnType"); if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(functionName)) { conf["functionName"] = functionName; } if (returnType != null && !Net.Vpc.Upa.Impl.Util.PlatformUtils.IsVoid(returnType)) { conf["returnType"] = returnType; } } if (callbackType != default(Net.Vpc.Upa.CallbackType)) { object instance = null; if (!Net.Vpc.Upa.Impl.Util.PlatformUtils.IsStatic(method)) { instance = persistenceUnit.GetFactory().GetSingleton <object>(type); } persistenceUnit.AddCallback(new Net.Vpc.Upa.CallbackConfig(instance, method, callbackType, callbackPhase, conf)); } }