public override void AfterModule(ModuleDefinition module)
 {
     foreach (var ie in Implementations.OfType <InterfaceBasedEventSource>())
     {
         module.Types.Remove(ie.Old);
     }
 }
        public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix)
        {
            var lites = this.ParseLiteKeys <Entity>();

            if (lites.IsEmpty())
            {
                return(Content(""));
            }

            object          queryName       = Finder.ResolveQueryName(webQueryName);
            Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll :
                                              Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray());

            var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext
            {
                Url = RouteHelper.New(),
                ControllerContext = this.ControllerContext,
                Lites             = lites,
                QueryName         = queryName,
                Implementations   = implementations,
                Prefix            = prefix,
            });

            if (items.IsNullOrEmpty())
            {
                return(Content(""));
            }

            var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml()));

            sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>"));
            return(Content(sb.ToHtml().ToString()));
        }
Beispiel #3
0
        internal static MetaExpression FromRoute(Type type, Implementations? implementations, PropertyRoute pr)
        {
            if (pr == null)
                return new MetaExpression(type.UnNullify().CleanType(), new DirtyMeta(implementations, new Meta[0]));

            return new MetaExpression(type.UnNullify().CleanType(), new CleanMeta(implementations, new[] { pr }));
        }
Beispiel #4
0
        public Implementations FindImplementations(PropertyRoute route)
        {
            if (route.PropertyRouteType == PropertyRouteType.LiteEntity)
            {
                route = route.Parent;
            }

            Type type = route.RootType;

            if (!Tables.ContainsKey(type))
            {
                return(Schema.Current.Settings.GetImplementations(route));
            }

            Field field = TryFindField(Table(type), route.Members);
            //if (field == null)
            //    return Implementations.ByAll;

            FieldReference refField = field as FieldReference;

            if (refField != null)
            {
                return(Implementations.By(refField.FieldType.CleanType()));
            }

            FieldImplementedBy ibField = field as FieldImplementedBy;

            if (ibField != null)
            {
                return(Implementations.By(ibField.ImplementationColumns.Keys.ToArray()));
            }

            FieldImplementedByAll ibaField = field as FieldImplementedByAll;

            if (ibaField != null)
            {
                return(Implementations.ByAll);
            }

            Implementations?implementations = CalculateExpressionImplementations(route);

            if (implementations != null)
            {
                return(implementations.Value);
            }

            var ss = Schema.Current.Settings;

            if (route.Follow(r => r.Parent)
                .TakeWhile(t => t.PropertyRouteType != PropertyRouteType.Root)
                .Any(r => ss.FieldAttribute <IgnoreAttribute>(r) != null))
            {
                var ib  = ss.FieldAttribute <ImplementedByAttribute>(route);
                var iba = ss.FieldAttribute <ImplementedByAllAttribute>(route);

                return(Implementations.TryFromAttributes(route.Type.CleanType(), route, ib, iba) ?? Implementations.By());
            }

            throw new InvalidOperationException("Impossible to determine implementations for {0}".FormatWith(route, typeof(IEntity).Name));
        }
 public static InjectionPlan Serialize(Implementations.InjectionPlan.InjectionPlan ip) 
 {
     if (ip is Implementations.InjectionPlan.Constructor) 
     {
         Implementations.InjectionPlan.Constructor cons = (Implementations.InjectionPlan.Constructor)ip;
         Implementations.InjectionPlan.InjectionPlan[] args = cons.GetArgs();
         InjectionPlan[] protoArgs = new InjectionPlan[args.Length];
         for (int i = 0; i < args.Length; i++) 
         {
             protoArgs[i] = Serialize(args[i]);
         }
         return NewConstructor(ip.GetNode().GetFullName(), protoArgs.ToList<InjectionPlan>());
     } 
     if (ip is Implementations.InjectionPlan.Subplan) 
     {
         Implementations.InjectionPlan.Subplan sp = (Implementations.InjectionPlan.Subplan)ip;
         Implementations.InjectionPlan.InjectionPlan[] args = sp.GetPlans();
         InjectionPlan[] subPlans = new InjectionPlan[args.Length];
         for (int i = 0; i < args.Length; i++) 
         {
             subPlans[i] = Serialize(args[i]);
         }
         return NewSubplan(ip.GetNode().GetFullName(), sp.GetSelectedIndex(), subPlans.ToList<InjectionPlan>());
     } 
     if (ip is CsInstance) 
     {
         CsInstance ji = (CsInstance)ip;
         return NewInstance(ip.GetNode().GetFullName(), ji.GetInstanceAsString());
     } 
     Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
             "Encountered unknown type of InjectionPlan: " + ip), LOGGER);
     return null;
 }
 public override void AfterModule(ModuleDefinition module)
 {
     foreach (var method in Implementations.SelectMany(ies => ies.New.Methods))
     {
         method.Body.OptimizeMacros();
     }
 }
Beispiel #7
0
        public override List<Lite<Entity>> Autocomplete(Implementations implementations, string subString, int count)
        {
            if (string.IsNullOrEmpty(subString))
                return new List<Lite<Entity>>();

            return AutocompleteUtils.FindLiteLike(implementations, subString, 5);
        }
Beispiel #8
0
        public DorukOtomotiv()
        {
            InitializeComponent();
            DataTable reportData = new Implementations().GetRportDataFromHTMLToDataTable();

            dataGridView1.DataSource = reportData;
        }
Beispiel #9
0
        public override Implementations?GetImplementations()
        {
            var cleanType = PropertyInfo.PropertyType.CleanType();

            if (!typeof(IEntity).IsAssignableFrom(cleanType))
            {
                return(null);
            }

            var fi = Reflector.TryFindFieldInfo(Parent.Type, PropertyInfo);

            if (fi != null)
            {
                return(Implementations.FromAttributes(cleanType, null,
                                                      fi.GetCustomAttribute <ImplementedByAttribute>(),
                                                      fi.GetCustomAttribute <ImplementedByAllAttribute>()));
            }

            if (cleanType.IsAbstract)
            {
                throw new InvalidOperationException("Impossible to determine implementations for {0}".FormatWith(PropertyInfo.PropertyName()));
            }

            return(Implementations.By(cleanType));
        }
Beispiel #10
0
    public static Implementations GetImplementations(PropertyRoute route)
    {
        if (!typeof(ModelEntity).IsAssignableFrom(route.RootType))
        {
            throw new InvalidOperationException("Route {0} is not rooted on a {1}".FormatWith(route, typeof(ModifiableEntity).Name));
        }

        PropertyRoute fieldRoute = route;

        if (fieldRoute.PropertyRouteType == PropertyRouteType.LiteEntity)
        {
            fieldRoute = fieldRoute.Parent !;
        }

        if (fieldRoute.PropertyRouteType == PropertyRouteType.MListItems)
        {
            fieldRoute = fieldRoute.Parent !;
        }

        return(Implementations.FromAttributes(
                   route.Type.CleanType(),
                   route,
                   fieldRoute.FieldInfo !.GetCustomAttribute <ImplementedByAttribute>(),
                   fieldRoute.FieldInfo !.GetCustomAttribute <ImplementedByAllAttribute>()));
    }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region previous reports
            //var reportData = new Implementations().GetReportData();

            /*
             * var sonuc = from c in reportData
             *          group c by new
             *          {
             *              c.WorkOrderID,
             *              c.DelayTypeID,
             *              c.DelayTypeName
             *          } into gcs
             *
             *          select new
             *          {
             *              isemri = gcs.Key.WorkOrderID,
             *              GecikmeTipi = gcs.Key.DelayTypeName,
             *              GecikmeSayisi = gcs.Count(),
             *              GecikmeToplamSüresi = gcs.Sum(x => x.DelayMinutes)
             *          };
             *
             * GridView1.AutoGenerateColumns = true;
             * GridView1.DataSource = sonuc.ToList();
             * GridView1.DataBind();
             *
             * GridView2.AutoGenerateColumns = true;
             * GridView2.DataSource = reportData.ToList();
             * GridView2.DataBind();
             */
            #endregion

            string s = new Implementations().GetRportHTMLFromReportData();
            Response.Write(s);
        }
Beispiel #12
0
 public override void BeforeModule(ModuleDefinition module)
 {
     foreach (var ie in Implementations.OfType <TemplateBasedEventSource>())
     {
         module.Types.Add(ie.New);
     }
 }
Beispiel #13
0
        public static void Initialise(TestContext testContext)
        {
            Implementations.Register(Factory.Singleton);

            Factory.Singleton.RegisterInstance <IApplicationInformation>(ApplicationInformation.Object);
            ApplicationInformation.Setup(a => a.CultureInfo).Returns((CultureInfo)null);
        }
Beispiel #14
0
    public PropertyRoute Add(MemberInfo member)
    {
        using (HeavyProfiler.LogNoStackTrace("PR.Add", () => member.Name))
        {
            if (member is MethodInfo && ((MethodInfo)member).IsInstantiationOf(MixinDeclarations.miMixin))
            {
                member = ((MethodInfo)member).GetGenericArguments()[0];
            }

            if (this.Type.IsIEntity() && PropertyRouteType != PropertyRouteType.Root)
            {
                Implementations imp = GetImplementations();

                Type?only;
                if (imp.IsByAll || (only = imp.Types.Only()) == null)
                {
                    throw new InvalidOperationException("Attempt to make a PropertyRoute on a {0}. Cast first".FormatWith(imp));
                }

                return(new PropertyRoute(Root(only), member));
            }

            return(new PropertyRoute(this, member));
        }
    }
Beispiel #15
0
 public DirtyMeta(Implementations? implementations, Meta[] properties)
     : base(implementations)
 {
     CleanMetas = properties.OfType<CleanMeta>().Concat(
         properties.OfType<DirtyMeta>().SelectMany(d => d.CleanMetas))
         .ToReadOnly();
 }
Beispiel #16
0
        public DynamicQueryBucket(object queryName, Func <IDynamicQueryCore> lazyQueryCore, Implementations entityImplementations)
        {
            if (lazyQueryCore == null)
            {
                throw new ArgumentNullException("lazyQueryCore");
            }

            this.QueryName             = queryName ?? throw new ArgumentNullException("queryName");
            this.EntityImplementations = entityImplementations;

            this.Core = new ResetLazy <IDynamicQueryCore>(() =>
            {
                var core = lazyQueryCore();

                core.QueryName = QueryName;

                core.StaticColumns.Where(sc => sc.IsEntity).SingleEx(() => "Entity column on {0}".FormatWith(QueryUtils.GetKey(QueryName)));

                core.EntityColumnFactory().Implementations = entityImplementations;

                var errors = core.StaticColumns.Where(sc => sc.Implementations == null && sc.Type.CleanType().IsIEntity()).CommaAnd(a => $"'{a.Name}'");

                if (errors.HasText())
                {
                    throw new InvalidOperationException("Column {0} of query '{1}' do(es) not have implementations deffined. Use Column extension method".FormatWith(errors, QueryUtils.GetKey(QueryName)));
                }

                return(core);
            });
        }
Beispiel #17
0
 public void AddListener(ListenerBase impl)
 {
     impl.OnAccept += (l, inStream, outStream) =>
     {
         Enroll(inStream, outStream);
     };
     Implementations.Add(impl);
 }
Beispiel #18
0
        public static void Initialise(TestContext testContext)
        {
            Implementations.Register(Factory.Singleton);

            global::VirtualRadar.Library.Implementations.Register(Factory.Singleton);   // <-- need IAircraftComparer defined for sort tests.
            global::VirtualRadar.Owin.Implementations.Register(Factory.Singleton);      // <-- need most of this for web API controller tests.
            global::VirtualRadar.WebServer.Implementations.Register(Factory.Singleton); // <-- need IResponder defined for response content tests.
        }
Beispiel #19
0
        bool IsNavigableEntity(object queryName)
        {
            var queryDescription = DynamicQueryManager.Current.QueryDescription(queryName);

            Implementations implementations = queryDescription.Columns.SingleEx(a => a.IsEntity).Implementations.Value;

            return(implementations.IsByAll || implementations.Types.Any(t => Navigator.IsNavigable(t, null, isSearch: true)));
        }
Beispiel #20
0
        internal static bool AllCanRead(this Implementations implementations, Func <Type, TypeAllowedAndConditions> getAllowed)
        {
            if (implementations.IsByAll)
            {
                return(true);
            }

            return(implementations.Types.All(t => getAllowed(t).MaxUI() != TypeAllowedBasic.None));
        }
Beispiel #21
0
        public static JsTypeInfo[] ToJsTypeInfos(this Implementations implementations, bool isSearch, string prefix)
        {
            if (implementations.IsByAll)
            {
                return(null);
            }

            return(implementations.Types.Select(t => ToJsTypeInfo(t, isSearch, prefix)).ToArray());
        }
Beispiel #22
0
        public override List <Lite <Entity> > Autocomplete(Implementations implementations, string subString, int count)
        {
            if (string.IsNullOrEmpty(subString))
            {
                return(new List <Lite <Entity> >());
            }

            return(Server.Return((IBaseServer bs) => bs.FindLiteLike(implementations, subString, 5)));
        }
Beispiel #23
0
        //--------------------//

        #region Clone
        /// <summary>
        /// Creates a deep copy of this <see cref="Selections"/> instance.
        /// </summary>
        /// <returns>The new copy of the <see cref="Selections"/>.</returns>
        public Selections Clone()
        {
            var selections = new Selections {
                UnknownAttributes = UnknownAttributes, UnknownElements = UnknownElements, InterfaceUri = InterfaceUri, Command = Command
            };

            selections.Implementations.AddRange(Implementations.CloneElements());
            return(selections);
        }
        public static void Serialize(string fileName, Implementations.InjectionPlan.InjectionPlan ip)
        {
            InjectionPlan plan = Serialize(ip);

            using (var file = File.Create(fileName))
            {
                Serializer.Serialize<InjectionPlan>(file, plan);
            }
        }
Beispiel #25
0
        static string TypeLinks(this Implementations implementations, Type type)
        {
            if (implementations.IsByAll)
            {
                return(HelpMessage.Any.NiceToString() + " " + type.TypeLink());
            }

            return(implementations.Types.CommaOr(TypeLink));
        }
        private void UpdateImplementation()
        {
            var selectedImlementation = _options.TestRunner;

            if (Implementations.Contains(selectedImlementation))
            {
                Implementation = selectedImlementation;
            }
        }
Beispiel #27
0
 public IEnumerator <T> GetEnumerator()
 {
     return(Client
            .LRange(Key, 0, -1)
            .Cast <string>()
            .Select(itemKey => Implementations.GetActivatorFor(typeof(T), Context, itemKey))
            .Select(act => act())
            .Cast <T>()
            .GetEnumerator());
 }
Beispiel #28
0
        public void AssertImplementedBy <T>(Expression <Func <T, object> > propertyRoute, Type typeToImplement) where T : Entity
        {
            var propRoute = PropertyRoute.Construct(propertyRoute);

            Implementations imp = GetImplementations(propRoute);

            if (imp.IsByAll || !imp.Types.Contains(typeToImplement))
            {
                throw new InvalidOperationException("Route {0} is not ImplementedBy {1}".FormatWith(propRoute, typeToImplement.Name));
            }
        }
Beispiel #29
0
        public void MetaConditional()
        {
            var dic = DynamicQueryCore.QueryMetadata(
                from a in Database.Query <AlbumEntity>()
                select new { Author = a.Id > 1 ? (ArtistEntity)a.Author : (IAuthorEntity)(BandEntity)a.Author }
                );

            DirtyMeta meta = (DirtyMeta)dic["Author"];

            Assert.Equal(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity)));
        }
Beispiel #30
0
        public void MetaCoallesce()
        {
            var dic = DynamicQuery.QueryMetadata(
                from a in Database.Query <AlbumEntity>()
                select new { Author = (ArtistEntity)a.Author ?? (IAuthorEntity)(BandEntity)a.Author }
                );

            DirtyMeta meta = (DirtyMeta)dic["Author"];

            Assert.AreEqual(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity)));
        }
Beispiel #31
0
        internal static List <Implementer> Resolve(Implementations implementations)
        {
            List <Implementer> implementers = new List <Implementer>();

            if (implementations.HasFlag(Implementations.INotifyPropertyChanged))
            {
                implementers.Add(new INotifyPropertyChangedImplementer());
            }

            return(implementers);
        }
Beispiel #32
0
        public static void Initialise(TestContext testContext)
        {
            Implementations.Register(Factory.Singleton);

            global::VirtualRadar.Library.Implementations.Register(Factory.Singleton);   // <-- need IAircraftComparer defined for sort tests.
            global::VirtualRadar.WebServer.Implementations.Register(Factory.Singleton); // <-- need IResponder defined for response content tests.

            AWhewell.Owin.Implementations.Register(Factory.Singleton);                  // <-- need Owin library registered for middleware tests
            AWhewell.Owin.Host.Ram.Implementations.Register(Factory.Singleton);         // <-- need RAM host library registered for controller tests
            AWhewell.Owin.WebApi.Implementations.Register(Factory.Singleton);           // <-- need Web API library registered for web API tests
        }
        static Implementations DefaultImplementations(Type type, object queryName)
        {
            var property = type.GetProperty("Entity", BindingFlags.Instance | BindingFlags.Public);

            if (property == null)
            {
                throw new InvalidOperationException("Entity property not found on query {0}".FormatWith(QueryUtils.GetKey(queryName)));
            }

            return(Implementations.By(property.PropertyType.CleanType()));
        }
        /// <summary>
        /// Gets a configuration type from the manager
        /// </summary>
        /// <param name="configType">The type of configuration to get</param>
        public object GetConfig(Type configType)
        {
            // If the implementation is not found, throw exception
            if (!Implementations.GetConfigImplementations().Any(x => x.Type == configType))
            {
                throw new ConfigNotFoundException($"Configuration of type {configType.ToString()} not found.");
            }

            // Return the runtime instance of the implementation
            return(Implementations.GetBaseImplementation(configType).RuntimeInstance);
        }
        /// <summary>
        /// Gets a configuration type from the manager
        /// </summary>
        /// <typeparam name="TConfig">The type of configuration to get</typeparam>
        public TConfig GetConfig <TConfig>()
        {
            // If the implementation is not found, throw exception
            if (!Implementations.GetConfigImplementations().Any(x => x.Type == typeof(TConfig)))
            {
                throw new ConfigNotFoundException($"Configuration of type {typeof(TConfig).ToString()} not found.");
            }

            // Return the runtime instance of the implementation
            return(Implementations.GetImplementation <TConfig>().RuntimeInstance);
        }
Beispiel #36
0
        public ExtensionToken(QueryToken parent, string key, Type type, bool isProjection,
            string unit, string format, 
            Implementations? implementations,
            string isAllowed, PropertyRoute propertyRoute)
            : base(parent)
        {
            var shouldHaveImplementations = typeof(IEntity).IsAssignableFrom((isProjection ? type.ElementType() : type).CleanType());

            if (shouldHaveImplementations && implementations == null)
                throw new ArgumentException("Extension token '{0}' (of type {1}) registered on type {2} has no implementations".FormatWith(key, type.TypeName(), parent.Type.CleanType().TypeName()));

            this.key= key;
            this.type = type;
            this.isProjection = isProjection;
            this.unit = unit;
            this.format = format;
            this.implementations = implementations;
            this.isAllowed = isAllowed;
            this.propertyRoute = propertyRoute;
        }
 void OnStepExecutedEvent(object sender, Implementations.Extenders.StepInfo e)
 {
     Console.WriteLine(e.Description);
 }
Beispiel #38
0
 protected Meta(Implementations? implementations)
 {
     this.Implementations = implementations;
 }
Beispiel #39
0
 public CleanMeta(Implementations? implementations, params PropertyRoute[] propertyRoutes)
     : base(implementations)
 {
     this.PropertyRoutes = propertyRoutes;
 }
        public TypeReferenceTS(Type type, Implementations? implementations)
        {
            this.IsCollection = type != typeof(string) && type != typeof(byte[]) && type.ElementType() != null;
            
            var clean = type == typeof(string) ? type :  (type.ElementType() ?? type);
            this.IsLite = clean.IsLite();
            this.IsNotNullable = clean.IsValueType && !clean.IsNullable();
            this.IsEmbedded = clean.IsEmbeddedEntity();

            if (this.IsEmbedded && !this.IsCollection)
                this.TypeNiceName = type.NiceName();

            this.Name = implementations?.Key() ?? TypeScriptType(type);
        }
Beispiel #41
0
        static MetaExpression MakeDirtyMeta(Type type, Implementations? implementations, params Expression[] expression)
        {
            var metas = expression.OfType<MetaExpression>().Select(a => a.Meta).NotNull().ToArray();

            return new MetaExpression(type, new DirtyMeta(implementations, metas));
        }
Beispiel #42
0
        internal static Implementations CastImplementations(Implementations implementations, Type cleanType)
        {
            if (implementations.IsByAll)
            {
                if (!Schema.Current.Tables.ContainsKey(cleanType))
                    throw new InvalidOperationException("Tye type {0} is not registered in the schema as a concrete table".Formato(cleanType));

                return Signum.Entities.Implementations.By(cleanType);
            }

            if (implementations.Types.All(cleanType.IsAssignableFrom))
                return implementations;

            return Signum.Entities.Implementations.By(implementations.Types.Where(cleanType.IsAssignableFrom).ToArray());
        }