static void Main()
        {
            List<Person> SULSdata = new List<Person>()
            {
                new SeniorTrainer("Spiro", "Spirov", 33),
                new JuniorTrainer("Kiro", "Kirov", 22),
                new GraduateStudent("Pesho", "Peshov", 77, 000001, 3.33),
                new GraduateStudent("Gosho", "Goshev", 77, 000002, 4.23),
                new DropoutStudent("Baba", "Yaga", 88, 000003, 6.00, "To fly more."),
                new DropoutStudent("Ivan", "Petrov", 18, 000006, 2.00, "No reason."),
                new OnsiteStudent("Yan", "Hon", 31, 000013, 3.50, "OOP", 2),
                new OnsiteStudent("Tzun", "Gvan", 19, 000019, 4.41, "OOP", 0),
                new OnlineStudent("Maria", "Georgieva", 21, 000119, 2.90, "OOP"),
                new OnlineStudent("Smilen", "Svilenov", 45, 000231, 3.80, "OOP"),
            };

            SULSdata.OfType<CurrentStudent>()
                .OrderBy(s => s.AverageGrade)
                .ToList()
                .ForEach(Console.WriteLine);

            Console.WriteLine();

            SULSdata.OfType<DropoutStudent>()
                .ToList()
                .ForEach(s => s.ReApply());
        }
        public void ExploreAssembly(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer, ManualResetEvent exitEvent)
        {
            var envoy = ProjectModelElementEnvoy.Create(project);
            if (assembly.ReferencedAssembliesNames.Any(n => n.Name == SilverlightMsTestAssemblyName))
            {
                var allElements = new List<IUnitTestElement>();
                var mappedElements = new Dictionary<IUnitTestElement, IUnitTestElement>();

                new mstestlegacy::JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestMetadataExplorer(msTestElementFactory, msTestAttributesProvider, project, shellLocks, allElements.Add)
                    .ExploreAssembly(assembly);

                foreach (var classElement in allElements.OfType<mstest10::JetBrains.ReSharper.UnitTestProvider.MSTest10.MsTestTestClassElement>())
                    mappedElements.Add(classElement, elementFactory.GetOrCreateClassElement(classElement.TypeName, project, envoy));

                foreach (var methodElement in allElements.OfType<mstest10::JetBrains.ReSharper.UnitTestProvider.MSTest10.MsTestTestMethodElement>())
                    mappedElements.Add(methodElement, elementFactory.GetOrCreateMethodElement(methodElement.Id, project, (mstestlegacy::JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestClassElementBase)mappedElements[methodElement.Parent], envoy, methodElement.TypeName));

                foreach (var rowElement in allElements.OfType<mstest10::JetBrains.ReSharper.UnitTestProvider.MSTest10.MsTestTestRowElement>())
                    mappedElements.Add(rowElement, elementFactory.GetOrCreateRowElement(rowElement.Id, project, (mstestlegacy::JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestMethodElementBase)mappedElements[rowElement.Parent], envoy));

                foreach (var element in allElements)
                {
                    IUnitTestElement mappedElement;
                    if (mappedElements.TryGetValue(element, out mappedElement))
                        consumer(mappedElements[element]);
                    else
                        consumer(element);
                }

            }
        }
        private void ProcessTodayPayments()
        {
            var todayPayments = _paymentSvc.GetTodayPayments(_expenseController.CurrentSessionData).ToList();
            var nextPayments = _paymentSvc.GetComingPayments(_expenseController.CurrentSessionData).ToList();
            var latePayments = _paymentSvc.GetLatePayments(_expenseController.CurrentSessionData).ToList();

            var form = new FormPendingExpensesViewModel(todayPayments, nextPayments, latePayments);
            form.ShowDialog();

            //when the form is closed, read the modified data and notify the worksheet.
            var processedPayments = new List<BaseTransaction>();
            processedPayments.AddRange(EditPendingExpenseDto.ToList(form.TodayPayments, w => w.IsOk == true));
            processedPayments.AddRange(EditPendingExpenseDto.ToList(form.LatePayments, w => w.IsOk == true));
            processedPayments.AddRange(EditPendingExpenseDto.ToList(form.NextPayments, w => w.IsOk == true));

            var processedExpenses = processedPayments.OfType<Expense>();
            var processedIncomes = processedPayments.OfType<Income>();
            _expenseController.AcceptDataCollection(processedExpenses, true);
            _incomeController.AcceptDataCollection(processedIncomes, true);

            CommandHandler.Run<ConfigureSidePanelCommand>(new SidePanelCommandArgs
                                                              {
                                                                  WpfControl = new MainSidePanel(),
                                                                  Transactions = CurrentSession.ValidTransactions,
                                                                  Accounts = CurrentSession.Accounts
                                                              });
        }
Example #4
0
        public static List<Block> Task(List<Block> blocks)
        {
            var media = blocks.OfType<MediaBlock>().Select(t => t.MediaQuery);
            var import = blocks.OfType<Model.Import>().Select(t => t.MediaQuery);
            var @using = blocks.OfType<Model.Using>().Select(t => t.MediaQuery);

            var toVerify = media.Union(import).Union(@using).ToList();

            toVerify.Each(v => VerifyQuery(v));

            var allProps =
                blocks.OfType<SelectorAndBlock>().SelectMany(s => s.Properties)
                .Union(
                    blocks.OfType<MediaBlock>().Select(m => m.Blocks).OfType<SelectorAndBlock>().SelectMany(s => s.Properties)
                );

            var values = allProps.OfType<NameValueProperty>().Select(s => s.Value).ToList();

            VerifyCycle(values);
            VerifySteps(values);
            VerifyCubicBezier(values);
            VerifyLinearGradient(values);

            return blocks;
        }
Example #5
0
        //public static List<FileAction> PerformRollup(List<USNChangeRange> range)
        //{
        //    var deletedFiles = range.Where(e=>  e.Entry)
        //}
        public static List<FileAction> PerformRollup(List<FileAction> toReturn)
        {
            var deletedFiles = toReturn.OfType<DeleteAction>().ToList();

            foreach (var deletedFile in deletedFiles)
            {
                if (toReturn.OfType<UpdateAction>().Select(f => f.RelativePath).Contains(deletedFile.RelativePath))
                {
                    toReturn.Remove(deletedFile);
                }

                toReturn.RemoveAll(f => f.RelativePath == deletedFile.RelativePath && f.USN < deletedFile.USN);
            }

            var fileActions = toReturn.Select(e => e.RelativePath).Distinct().Select(f => toReturn.FirstOrDefault(a => a.RelativePath == f)).ToList();

            foreach (var source in fileActions.OfType<RenameAction>().ToList())
            {
                if (fileActions.Any(f => f.RawPath == source.RenameFrom))
                {
                    fileActions.RemoveAll(f => f.RawPath == source.RenameFrom);
                    fileActions.Remove(source);
                    fileActions.Add(new RenameAction()
                    {
                        RelativePath = source.RelativePath,
                        RawPath = source.RawPath,
                        USN = source.USN,
                        IsDirectory = source.IsDirectory,
                        Mountpoint = source.Mountpoint
                    });
                }
            }

            return fileActions;
        }
Example #6
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OpenIdChannel"/> class.
		/// </summary>
		/// <param name="messageTypeProvider">A class prepared to analyze incoming messages and indicate what concrete
		/// message types can deserialize from it.</param>
		/// <param name="bindingElements">The binding elements to use in sending and receiving messages.</param>
		protected OpenIdChannel(IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements)
			: base(messageTypeProvider, bindingElements) {
			Requires.NotNull(messageTypeProvider, "messageTypeProvider");

			// Customize the binding element order, since we play some tricks for higher
			// security and backward compatibility with older OpenID versions.
			var outgoingBindingElements = new List<IChannelBindingElement>(bindingElements);
			var incomingBindingElements = new List<IChannelBindingElement>(bindingElements);
			incomingBindingElements.Reverse();

			// Customize the order of the incoming elements by moving the return_to elements in front.
			var backwardCompatibility = incomingBindingElements.OfType<BackwardCompatibilityBindingElement>().SingleOrDefault();
			var returnToSign = incomingBindingElements.OfType<ReturnToSignatureBindingElement>().SingleOrDefault();
			if (backwardCompatibility != null) {
				incomingBindingElements.MoveTo(0, backwardCompatibility);
			}
			if (returnToSign != null) {
				// Yes, this is intentionally, shifting the backward compatibility
				// binding element to second position.
				incomingBindingElements.MoveTo(0, returnToSign);
			}

			this.CustomizeBindingElementOrder(outgoingBindingElements, incomingBindingElements);

			// Change out the standard web request handler to reflect the standard
			// OpenID pattern that outgoing web requests are to unknown and untrusted
			// servers on the Internet.
			this.WebRequestHandler = new UntrustedWebRequestHandler();
		}
Example #7
0
        public SpatialRecord Map(ISOSpatialRow isoSpatialRow, List<WorkingData> meters)
        {
            var spatialRecord = new SpatialRecord();

            foreach (var meter in meters.OfType<NumericWorkingData>())
            {
                SetNumericMeterValue(isoSpatialRow, meter, spatialRecord);
            }

            foreach (var meter in meters.OfType<EnumeratedWorkingData>())
            {
                SetEnumeratedMeterValue(isoSpatialRow, meter, spatialRecord);
            }

            spatialRecord.Geometry = new ApplicationDataModel.Shapes.Point
            {
                X = Convert.ToDouble(isoSpatialRow.EastPosition * CoordinateMultiplier),
                Y = Convert.ToDouble(isoSpatialRow.NorthPosition * CoordinateMultiplier),
                Z = isoSpatialRow.Elevation
            };

            spatialRecord.Timestamp = isoSpatialRow.TimeStart;

            return spatialRecord;
        }
        private static dynamic ReadJsonArray(JsonReader reader)
        {
            List<dynamic> vals = new List<dynamic>();

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.EndArray)
                {
                    break;
                }
                else
                {
                    vals.Add(ReadJsonValue(reader, true));
                }
            }

            if (vals.Count != 0 && vals.All(v => v is IDictionary<string, object>))
            {
                if (vals.OfType<IDictionary<string, object>>().All(v => v.ContainsKey("Key") && v.ContainsKey("Value")))
                {
                    ExpandoObject obj = new ExpandoObject();

                    foreach (IDictionary<string, object> dict in vals.OfType<IDictionary<string, object>>())
                    {
                        ((IDictionary<string, object>)obj).Add(dict["Key"].ToString(), dict["Value"]);
                    }

                    return obj;
                }
            }

            return vals;
        }
Example #9
0
        public static GenericStructure CreateCopyStream(List<MapObject> objects)
        {
            var stream = new GenericStructure("clipboard");

            var entitySolids = objects.OfType<Entity>().SelectMany(x => x.Find(y => y is Solid)).ToList();
            stream.Children.AddRange(objects.OfType<Solid>().Where(x => !x.IsCodeHidden && !x.IsVisgroupHidden && !entitySolids.Contains(x)).Select(WriteSolid));
            stream.Children.AddRange(objects.OfType<Group>().Select(WriteGroup));
            stream.Children.AddRange(objects.OfType<Entity>().Select(WriteEntity));

            return stream;
        }
Example #10
0
        public static List<Block> Task(List<Block> blocks)
        {
            var media = blocks.OfType<MediaBlock>().Select(t => t.MediaQuery);
            var import = blocks.OfType<Model.Import>().Select(t => t.MediaQuery);
            var @using = blocks.OfType<Model.Using>().Select(t => t.MediaQuery);

            var toVerify = media.Union(import).Union(@using).ToList();

            toVerify.Each(v => VerifyQuery(v));

            return blocks;
        }
Example #11
0
        public static List<Block> Task(List<Block> blocks)
        {
            var resets = blocks.OfType<SelectorAndBlock>().Where(w => w.IsReset).ToList();

            var ret = new List<Block>();
            ret.AddRange(blocks.Where(w => !(w is SelectorAndBlock || w is MediaBlock)));
            ret.AddRange(blocks.OfType<SelectorAndBlock>().Where(w => w.IsReset));

            var remaining = blocks.Where(w => !ret.Contains(w)).ToList();

            foreach (var block in remaining)
            {
                var selBlock = block as SelectorAndBlock;
                if (selBlock != null)
                {
                    var props = new List<Property>();

                    var resetProps = selBlock.Properties.OfType<ResetProperty>();
                    var selfResetProps = selBlock.Properties.OfType<ResetSelfProperty>();

                    props.AddRange(selBlock.Properties.Where(w => !(resetProps.Contains(w) || selfResetProps.Contains(w))));

                    var copySels = resetProps.Select(x => x.Selector).Union(selfResetProps.Select(x => x.EffectiveSelector)).ToList();

                    foreach (var sel in copySels)
                    {
                        var newProps = FindMatches(sel, resets);

                        foreach (var p in newProps)
                        {
                            // reset properties never override
                            if (props.Any(a => a is NameValueProperty && ((NameValueProperty)a).Name.Equals(p.Name, StringComparison.InvariantCultureIgnoreCase))) continue;

                            props.Add(p);
                        }
                    }

                    ret.Add(new SelectorAndBlock(selBlock.Selector, props, null, selBlock.Start, selBlock.Stop, selBlock.FilePath));
                }

                var media = block as MediaBlock;
                if (media != null)
                {
                    var subBlocks = Task(media.Blocks.ToList());

                    ret.Add(new MediaBlock(media.MediaQuery, subBlocks, media.Start, media.Start, media.FilePath));
                }
            }

            return ret;
        }
        public RequestMetadata GetRequestMetadata(RequestLog source)
        {
            var entries = new List<object>(source.LogTable.Rows.Count);

            foreach (DataRow row in source.LogTable.Rows)
            {
                try
                {
                    object entry = mEntryFactory.CreateEntry(row);
                    if (entry != null)
                    {
                        entries.Add(entry);
                    }
                }
                catch (ArgumentException exception)
                {
                    Trace.TraceWarning(exception.Message);
                }
            }

            var commandEntries = entries.OfType<CommandEntry>();

            return new RequestMetadata
            {
                Entries = entries,
                Statistics = new RequestMetadataStatistics
                {
                    TotalCommands = commandEntries.LongCount(),
                    TotalDuration = commandEntries.Aggregate(TimeSpan.Zero, (value, entry) => value + entry.Duration),
                    TotalBytesReceived = commandEntries.Sum(x => x.BytesReceived),
                    TotalBytesSent = commandEntries.Sum(x => x.BytesSent),
                    TotalDuplicateCommands = commandEntries.LongCount(x => x.IsDuplicate)
                }
            };
        }
Example #13
0
		public AppConfig( string configFile ) {
			this.saveFile = configFile;
			this.configState = ConfigState.Loading;
			this.currencies = new List<Currency>(24);
			try {
				config = Configuration.LoadFromFile(configFile, Encoding.UTF8);
				foreach (Section sec in config) {
					Currency c = sec.CreateObject<Currency>();
					if (sec["Name"].StringValue.Contains("Chaos")) { c.Value = 1; }
					this.currencies.Add(c);
				}
			}
			catch (Exception) {
				InitializeCurrency();
				config = new Configuration();
				byte id = 0;
				var currencyData = currencies.OfType<Currency>().OrderBy(item => item.Name).GetEnumerator();
				while (currencyData.MoveNext()) {
					config.Add(Section.FromObject(SECTION_CURRENCY + id, currencyData.Current));
					id++;
				}
				config.SaveToFile(configFile, Encoding.UTF8);
			}
			configState = ConfigState.Clean;
		}
        private void RegisterHandles()
        {
            UIResizeOperationHandleConnector = new UIResizeOperationHandleConnector(CanvasItem, FrameOfReference,
                SnappingEngine);


            var thumbContainer = (UIElement) FindName("PART_ThumbContainer");

            Debug.Assert(thumbContainer != null, "ThumbContainer part not found!");

            var visualChildren = new List<DependencyObject>();
            for (var i = 0; i < VisualTreeHelper.GetChildrenCount(thumbContainer); i++)
            {
                visualChildren.Add(VisualTreeHelper.GetChild(thumbContainer, i));
            }

            var logicalChildren = visualChildren.OfType<FrameworkElement>();
            foreach (var logicalChild in logicalChildren)
            {


                var childRect = this.GetRectRelativeToParent(logicalChild);

                var parentRect = CanvasItem.Rect();

                var handlePoint = childRect.GetHandlePoint(parentRect.Size);

                UIResizeOperationHandleConnector.RegisterHandle(new UIElementAdapter(logicalChild), handlePoint);                
            }
        }
Example #15
0
		public Machine(byte[] appleIIe, byte[] diskIIRom)
		{
			Events = new MachineEvents();

			Cpu = new Cpu(this);
			Memory = new Memory(this, appleIIe);
			Keyboard = new Keyboard(this);
			GamePort = new GamePort(this);
			Cassette = new Cassette(this);
			Speaker = new Speaker(this);
			Video = new Video(this);
			NoSlotClock = new NoSlotClock(this);

			var emptySlot = new PeripheralCard(this);
			Slot1 = emptySlot;
			Slot2 = emptySlot;
			Slot3 = emptySlot;
			Slot4 = emptySlot;
			Slot5 = emptySlot;
			Slot6 = new DiskIIController(this, diskIIRom);
			Slot7 = emptySlot;

			Slots = new List<PeripheralCard> { null, Slot1, Slot2, Slot3, Slot4, Slot5, Slot6, Slot7 };
			Components = new List<MachineComponent> { Cpu, Memory, Keyboard, GamePort, Cassette, Speaker, Video, NoSlotClock, Slot1, Slot2, Slot3, Slot4, Slot5, Slot6, Slot7 };

			BootDiskII = Slots.OfType<DiskIIController>().Last();
		}
Example #16
0
        public static List<Block> Task(List<Block> blocks)
        {
            var inputFile = Current.InitialFilePath;

            var spriteDecls = blocks.OfType<SpriteBlock>().ToList();
            if (spriteDecls.Count == 0)
            {
                return blocks;
            }

            var ret = blocks.Where(w => w.GetType() != typeof(SpriteBlock)).ToList();

            foreach (var sprite in spriteDecls)
            {
                var output = sprite.OutputFile.Value.RebaseFile(inputFile);

                var input = sprite.Sprites.ToDictionary(k => k.MixinName, v => v.SpriteFilePath.Value.RebaseFile(inputFile));

                var export = SpriteExport.Create(output, inputFile, input);
                Current.SpritePending(export);

                ret.AddRange(export.MixinEquivalents());

                Current.Dependecies.SpritesResolved(sprite);
            }

            return ret;
        }
Example #17
0
		private bool ValidateVersion(List<Plan> folders)
		{
			bool result = true;
			foreach (var plan in folders.OfType<Plan>())
				result &= ValidateVersion(plan);
			return result;
		}
        public CollectionQuerySimplification(List<object> coll)
        {
            var x = coll.Select(element => element as object).Any(element => element != null);  // Noncompliant use OfType
            x = coll.Select((element) => ((element as object))).Any(element => (element != null) && CheckCondition(element) && true);  // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object); // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object[]);
            y = coll.Where(element => element is object).Select(element => (object)element); // Noncompliant use OfType
            x = coll.Where(element => element == null).Any();  // Noncompliant use Any([expression])
            var z = coll.Where(element => element == null).Count();  // Noncompliant use Count([expression])
            z = Enumerable.Count(coll.Where(element => element == null));  // Noncompliant
            z = Enumerable.Count(Enumerable.Where(coll, element => element == null));  // Noncompliant
            y = coll.Select(element => element as object);
            y = coll.ToList().Select(element => element as object); // Noncompliant
            y = coll
                .ToList()  // Noncompliant
                .ToArray() // Noncompliant
                .Select(element => element as object);

            var z = coll
                .Select(element => element as object)
                .ToList();

            var c = coll.Count(); //Noncompliant
            c = coll.OfType<object>().Count();

            x = Enumerable.Select(coll, element => element as object).Any(element => element != null); //Noncompliant
            x = Enumerable.Any(Enumerable.Select(coll, element => element as object), element => element != null); //Noncompliant
        }
Example #19
0
 private static void ListKicks(List<LogMessage> messages)
 {
     foreach (var kick in messages.OfType<KickedMessage>())
     {
         Console.WriteLine(kick);
     }
 }
Example #20
0
        private Portal _stagePortal; // Can be null

        #endregion Fields

        #region Constructors

        protected World(WorldMap worldMap, List<GameObject> gameObjects, List<DoorGroup> doorGroups)
        {
            _worldMap = worldMap;
            _timeBonuses = gameObjects.OfType<TimeBonus>().ToList();
            _springs = gameObjects.OfType<Spring>().ToList();
            _keys = gameObjects.OfType<Key>().ToList();
            _cannons = gameObjects.OfType<Cannon>().ToList();
            _doors = gameObjects.OfType<Door>().ToList();
            _doorGroups = doorGroups;

            _readOnlyTimeBonuses = new ReadOnlyCollection<TimeBonus>(_timeBonuses);
            _readOnlySprings = new ReadOnlyCollection<Spring>(_springs);
            _readOnlyKeys = new ReadOnlyCollection<Key>(_keys);
            _readOnlyCannons = new ReadOnlyCollection<Cannon>(_cannons);
            _readOnlyDoors = new ReadOnlyCollection<Door>(_doors);
        }
Example #21
0
        public static List<Block> Task(List<Block> blocks)
        {
            var charsets = blocks.OfType<CssCharset>();

            if (charsets.Count() == 0) return blocks;

            var ret = new List<Block>(blocks.Count);
            ret.AddRange(blocks.Where(w => !(w is CssCharset)));

            var charsetStrings = charsets.Select(s => s.Charset.Value).Distinct();

            if (charsetStrings.Count() != 1)
            {
                foreach (var c in charsets)
                {
                    var others = string.Join(", ", charsetStrings.Where(s => s != c.Charset.Value));

                    Current.RecordError(ErrorType.Compiler, c, "@charset conflicts with " + others + ", defined elsewhere.");
                }

                return null;
            }

            ret.Insert(0, new CssCharset(new QuotedStringValue(charsetStrings.Single()), -1, -1));

            return ret;
        }
Example #22
0
 public void SetFilters(List<IFilter> filters)
 {
     foreach (var filter in filters.OfType<ContainsTextFilter>())
     {
         filterPanel.Controls.Add(new ContainsTextFilterControl { Filter = filter });
     }
 }
        private static void EnsureLoaded()
        {
            if (itemDefinitions == null)
            {
                // Items sammeln
                itemDefinitions = new List<IItemDefinition>();
                itemDefinitions.AddRange(ExtensionManager.GetInstances<IItemDefinition>());

                // Ressourcen sammeln
                resourceDefinitions = new List<IResourceDefinition>();
                resourceDefinitions.AddRange(itemDefinitions.OfType<IResourceDefinition>());

                // Blöcke sammeln
                blockDefinitions = itemDefinitions.OfType<IBlockDefinition>().ToArray();
            }
        }
Example #24
0
 public void AddOptions(List<Object> addOptions)
 {
     Options.Clear();
     addOptions = addOptions.GroupBy(optionObject => optionObject).Select(test => test.Key).ToList(); //remove duplicates
     foreach (Entity civ in addOptions.OfType<Entity>())
         Options.Add(new MapMenuOption(this, civ));
     foreach (Site site in addOptions.OfType<Site>())
         Options.Add(new MapMenuOption(this, site));
     foreach (Battle battle in addOptions.OfType<Battle>())
         Options.Add(new MapMenuOption(this, battle));
     foreach (List<Battle> battles in addOptions.OfType<List<Battle>>())
         Options.Add(new MapMenuOption(this, battles));
     foreach (string text in addOptions.OfType<string>())
         Options.Add(new MapMenuOption(this, text));
     CalculateSize();
 }
Example #25
0
        protected internal override List<CobieObject> MergeDuplicates(List<CobieObject> objects, TextWriter log)
        {
            var candidates = objects.OfType<Zone>().ToList();
            if (!candidates.Any()) return new List<CobieObject>();

            var categoryStrings = (Categories ?? new List<Category>()).Select(c => c.CategoryString);
            var duplicates =
                candidates.Where(
                    s => s.Name == Name)
                    .ToList();
            duplicates.Remove(this);
            if (!duplicates.Any()) return new List<CobieObject>();

            //get all components into this one
            foreach (var duplicate in duplicates)
            {
                if (duplicate.Spaces == null) continue;
                Spaces.AddRange(duplicate.Spaces);

                //check if the category is the same. It doesn't have to be according to COBie specification as it is a compound
                //key but it would make any attached attributes ambiguous
                var categoryDif = duplicate.Categories.Where(c => !categoryStrings.Contains(c.CategoryString)).ToList();
                if (categoryDif.Any())
                    log.WriteLine(
                        "There are multiple systems with the same name but different category. This is a legal in COBie sheet but will make any attributes related to this object ambiguous. Object: {0}, different category: {1}",
                        duplicate.Name, String.Join("; ", categoryDif.Select(c => c.CategoryString)));
            }

            return duplicates.Cast<CobieObject>().ToList();
        }
Example #26
0
 public static AphidMacro[] Parse(List<AphidExpression> ast)
 {
     return ast
         .OfType<BinaryOperatorExpression>()
         .Select(x => new
         {
             Id = x.LeftOperand as IdentifierExpression,
             Call = x.RightOperand as CallExpression,
             Original = x,
         })
         .Where(x => x.Id != null && x.Call != null && x.Call.Args.Count() == 1)
         .Select(x => new
         {
             Name = x.Id.Identifier,
             CallName = x.Call.FunctionExpression as IdentifierExpression,
             Func = x.Call.Args.Single() as FunctionExpression,
             x.Original,
         })
         .Where(x =>
             x.CallName != null &&
             x.CallName.Identifier == "macro" &&
             x.Func != null)
         .Select(x => new AphidMacro(x.Name, x.Func, x.Original))
         .ToArray();
 }
        protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
        {
            //不希望覆寫太多東西,所以大部分還是用base的CreateMetadata方法
            ModelMetadata metadata = base.CreateMetadata(attributes,
                                                          containerType,
                                                          modelAccessor,
                                                          modelType,
                                                          propertyName);

            List<Attribute> attributeList = new List<Attribute>(attributes);

            IEnumerable<UIHintAttribute> uiHintAttributes = attributeList.OfType<UIHintAttribute>();
            UIHintAttribute uiHintAttribute = uiHintAttributes.FirstOrDefault(a => String.Equals(a.PresentationLayer, "MVC", StringComparison.OrdinalIgnoreCase))
                                            ?? uiHintAttributes.FirstOrDefault(a => String.IsNullOrEmpty(a.PresentationLayer));

            //如果有UIHint屬性,就將他的參數塞到ModelMetadata.AdditionalValues裡面
            //Key是UIHintTemplateControlParameters
            if (uiHintAttribute != null)
            {
                if (metadata.AdditionalValues.ContainsKey("UIHintTemplateControlParameters"))
                    throw new ArgumentException("Metadate.AdditionalValues已存在 \"UIHintTemplateControlParameters\"這個Key,請更換擴充UIHintAttribute的Key值。");

                metadata.AdditionalValues.Add("UIHintTemplateControlParameters", uiHintAttribute.ControlParameters);
            }
            return metadata;
        }
Example #28
0
        public UsageGraph(string appName, Type commandType)
        {
            _appName = appName;
            _commandType = commandType;
            _inputType = commandType.FindInterfaceThatCloses(typeof (IFubuCommand<>)).GetGenericArguments().First();

            _commandName = CommandFactory.CommandNameFor(commandType);
            _commandType.ForAttribute<CommandDescriptionAttribute>(att => { _description = att.Description; });

            if (_description == null) _description = _commandType.Name;

            _handlers = InputParser.GetHandlers(_inputType);

            _commandType.ForAttribute<UsageAttribute>(att =>
            {
                _usages.Add(buildUsage(att));
            });

            if (!_usages.Any())
            {
                var usage = new CommandUsage()
                {
                    AppName = _appName,
                    CommandName = _commandName,
                    UsageKey = "default",
                    Description = _description,
                    Arguments = _handlers.OfType<Argument>(),
                    ValidFlags = _handlers.Where(x => !(x is Argument))
                };

                _usages.Add(usage);
            }
        }
Example #29
0
        public APIIndex(List<DoxygenModule> InModules)
            : base(null, "API")
        {
            // Build a mapping of module names to modules
            Dictionary<string, DoxygenModule> NameToModuleMap = new Dictionary<string,DoxygenModule>();
            foreach(DoxygenModule Module in InModules)
            {
                NameToModuleMap.Add(Module.Name, Module);
            }

            // Create a module category tree
            APIModuleCategory RootCategory = new APIModuleCategory(null);
            RootCategory.AddModules(InModules.Select(x => new KeyValuePair<string, string>(x.Name, x.BaseSrcDir)).ToArray());
            Debug.Assert(RootCategory.MinorModules.Count == 0 && RootCategory.MajorModules.Count == 0);

            // Create all the index pages
            foreach (APIModuleCategory Category in RootCategory.Categories)
            {
                if (!Category.IsEmpty)
                {
                    APIModuleIndex ModuleIndex = new APIModuleIndex(this, Category, InModules);
                    ModuleIndexes.Add(ModuleIndex);
                }
            }
            Pages.AddRange(ModuleIndexes);

            // Get all the members that were created as part of building the modules. After this point we'll only create index pages.
            List<APIMember> AllMembers = new List<APIMember>(GatherPages().OfType<APIMember>().OrderBy(x => x.FullName));
            foreach (APIMember Member in AllMembers)
            {
                Member.Link();
            }
            foreach (APIMember Member in AllMembers)
            {
                Member.PostLink();
            }

            // Create an index of all the constants
            ConstantIndex = new APIConstantIndex(this, AllMembers);
            Pages.Add(ConstantIndex);

            // Create an index of all the functions
            FunctionIndex = new APIFunctionIndex(this, AllMembers.OfType<APIFunction>().Where(x => !(x.ScopeParent is APIRecord)));
            Pages.Add(FunctionIndex);

            // Create an index of all the types
            TypeIndex = new APITypeIndex(this, AllMembers);
            Pages.Add(TypeIndex);

            // Create an index of all the classes
            RecordHierarchy = APIHierarchy.Build(this, AllMembers.OfType<APIRecord>());
            Pages.Add(RecordHierarchy);

            // Create all the quick links
            foreach (string QuickLinkPath in QuickLinkPaths)
            {
                APIMember Member = AllMembers.FirstOrDefault(x => x.LinkPath == QuickLinkPath);
                if (Member != null) QuickLinks.Add(Member);
            }
        }
Example #30
0
        public override void BeginInit()
        {
            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys = new List<ModifierKeyBase>();
            _allLogicalKeys = new List<ILogicalKey>();
            _allOnScreenKeys = new List<OnScreenKey>();

            _sections = new ObservableCollection<OnScreenKeyboardSection>();

            var mainSection = new OnScreenKeyboardSection();
            var mainKeys = GetMainKeys();

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);
            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(3, GridUnitType.Star)});
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);

            _modifierKeys.AddRange(_allLogicalKeys.OfType<ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }