protected IProcessResponse CreateFailureResponse(Exception ex, EntityDomain domain)
 {
     while (ex.InnerException != null) ex = ex.InnerException;
     MessageProcessResponse message = CreateMessageResponse(ex.Message, MessageProcessResponseType.Failure);
     if (domain == null) return message;
     return new InputProcessResponse(domain, message) { URI = URI };
 }
 protected static bool CanProcess(MethodBase method, EntityDomain domain, object domainId)
 {
     ParameterInfo[] parameters = method.GetParameters();
     if (method.IsStatic) return parameters.Length == 0 || domain != null;
     return (parameters.Length == 0 && domainId != null)
            || (domain != null && domainId != null);
 }
Exemple #3
0
        public EntitySchema(Type type, EntityDomain entity)
        {
            if (type == null) throw new ArgumentNullException("type");
            EntityType = type;
            Label = CoreSection.Current.GetLocalizationString(EntityType);

            Query = GetQueryMethod();
            Constructors = GetConstructorMethods();
            StaticMethods = GetStaticMethods();
            InstanceMethods = GetInstanceMethods(entity);
        }
        public NamespaceSchema(string name, EntityDomain[] entityDomains)
            : this(name)
        {
            var types = new List<Type>();
            Array.ForEach(entityDomains, d => types.Add(d.Type));
            IEnumerator<Type> enumerator = types.GetEnumerator();

            if (enumerator.MoveNext())
                Label = CoreSection.Current.GetLocalizationString(enumerator.Current, Name);

            if (Label.Equals(Name))
                Label = Label.Substring(Label.LastIndexOf(Domain.TypeSeparator, StringComparison.Ordinal) + 1);

            CreateChildElements(entityDomains);
        }
Exemple #5
0
        private static QueryProcessResponse CreateResponse(Type type, IEnumerable items, ProcessURI uri)
        {
            var domains = new DomainCollection();
            var enumerator = items.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var instance = enumerator.Current;
                var entity = new EntityDomain(type, uri)
                {
                    Instance = instance,
                    Value = ContextFactory.GetContext(type).GetID(instance),
                };

                domains.Add(entity);
            }
            return new QueryProcessResponse(type, domains) { URI = uri };
        }
        private void FillSubItems(Dictionary<string, object> data, object value)
        {
            int index = 0;
            do
            {
                string key = string.Format(FieldPrefixFormat, String.Concat(UniqueID, value), index);
                EntityDomain domain;

                if ((data[key] == null) || (string.IsNullOrEmpty(data[key].ToString())))
                    domain = new EntityDomain(Type, new ProcessURI(), data[key]);
                else
                    domain = new EntityDomain(Type, URI, data[key]);

                domain.Domains.ForEach(argument =>
                {
                    string argumentKey = string.Concat(key, argument.ID);
                    /*if (argument is EntityCollectionDomain)
                        argument.Fill(data);
                    else*/
                    if (data.ContainsKey(argumentKey))
                    {
                        argument.Value = data[argumentKey];
                        if (CoreSection.Current.IsEntity(argument.Type))
                            ((EntityDomain)argument).Instance = ContextFactory.GetContext(argument.Type).Get(argument.Value.ToString(), argument.Type);
                    }
                });
                Domains.Add(domain);
                index++;
            } while (data.ContainsKey(string.Format(FieldPrefixFormat, String.Concat(UniqueID, value), index)));
        }
Exemple #7
0
 private List<ProcessSchema> GetInstanceMethods(EntityDomain entity)
 {
     List<ProcessSchema> methods = GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.DeclaredOnly);
     if (entity != null && entity.Value != null)
         methods.ForEach(ps => ps.URI.Argument.Values.Add(entity.Value.ToString()));
     return methods;
 }
Exemple #8
0
 public static EntitySchema GetEntitySchema(EntityDomain domain)
 {
     return Schema.FindEntity(domain.Type);
 }
 internal InputProcessResponse(EntityDomain domain, MessageProcessResponse message)
     : base(message.Message, message.MessageType, null)
 {
     Domain = domain;
 }
 public InputProcessResponse(EntityDomain domain)
 {
     Domain = domain;
 }
 private void CreateChildElements(EntityDomain[] entityDomains)
 {
     Array.ForEach(entityDomains, entity =>
                                     {
                                         if (entity.Type.Namespace != null && entity.Type.Namespace.Equals(Name) &&
                                             entity.Type.IsPublic && !entity.Type.IsNested &&
                                             !entity.Type.IsAbstract && !entity.Type.IsEnum &&
                                             !IsLocalizationType(entity.Type) &&
                                             !CoreSection.IsExcludedEntity(entity.Type))
                                             Entities.Add(new EntitySchema(entity.Type, entity));
                                     });
 }