public MonstersViewModel(ILibrary library, IEventAggregator eventAggregator)
 {
     this.DisplayName = "monsters";
     this.eventAggregator = eventAggregator;
     this.library = library;
     this.items = this.library.Monsters;
 }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Signal[] outputs = new Signal[manipulatedInputs.Count];
                    ReadOnlySignalSet cotangents = StdBuilder.Cotangent(port.InputSignals);
                    for(int i = 0; i < outputs.Length; i++)
                        outputs[i] = Std.Multiply(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
                    return StdBuilder.Negate(outputs);
                }));

            MathIdentifier typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
            ITheoremProvider basicProvider;
            if(!library.TryLookupTheoremType(typeId, out basicProvider))
            {
                basicProvider = Binder.GetInstance<ITransformationTheoremProvider, MathIdentifier>(typeId);
                library.AddTheoremType(basicProvider);
            }
            ((ITransformationTheoremProvider)basicProvider).Add(
                new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    return StdBuilder.Invert(StdBuilder.Sine(transformedInputs));
                    //Signal[] ret = new Signal[transformedInputs.Count];
                    //for(int i = 0; i < ret.Length; i++)
                    //    ret[i] = Std.Invert(Std.Sine(transformedInputs[i]));
                    //return ret;
                }));
        }
예제 #3
0
        public FeedsViewModel(ILibrary library, IFeedRepository feedRepository)
        {
            this.library = library;
            this.feedRepository = feedRepository;

            refreshTimer = new Timer(RefreshFeeds, null, (int)TimeSpan.FromMinutes(1).TotalMilliseconds, Timeout.Infinite);
        }
예제 #4
0
 private string[] GetNetFxVersions(ILibrary library, FeatureTable table)
 {
     return table.Features.Where(f => table[library, f].State == FeatureState.Success)
                          .Select(f => (IGrouping<string, FrameworkName>)f.Key)
                          .Select(g => VersionUtility.GetShortFrameworkName(g.First()))
                          .ToArray();
 }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    return StdBuilder.Negate(manipulatedInputs);
                }));

            Algebra.AutoSimplifyTransformation.Provider.Add(
                new Algebra.AutoSimplifyTransformation(_entityId,
                delegate(Port port)
                {
                    // TODO
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    if(manipulatedInputs.Count == 0)
                            return new SignalSet(IntegerValue.ConstantAdditiveIdentity);
                    if(manipulatedInputs.Count == 1)
                    {
                        Signal s = manipulatedInputs[0];
                        if(Std.IsConstantAdditiveIdentity(s))
                            return new SignalSet(s);
                        return new SignalSet(Std.Negate(s));
                    }
                    if(hasManipulatedInputs)
                        return new SignalSet(StdBuilder.Negate(manipulatedInputs));
                    return port.OutputSignals;
                }));
        }
예제 #6
0
        public ILibrary AddReference(ILibrary library)
        {
            // Add
            References.Add(library);

            return library;
        }
예제 #7
0
        public static void Run(ILibrary library)
        {
            var options = new DriverOptions();

            var Log = new TextDiagnosticPrinter();
            var driver = new Driver(options, Log);

            library.Setup(driver);
            driver.Setup();

            if(driver.Options.Verbose)
                Log.Level = DiagnosticKind.Debug;

            if (!options.Quiet)
                Log.EmitMessage("Parsing libraries...");

            if (!driver.ParseLibraries())
                return;

            if (!options.Quiet)
                Log.EmitMessage("Indexing library symbols...");

            driver.Symbols.IndexSymbols();

            if (!options.Quiet)
                Log.EmitMessage("Parsing code...");

            if (!driver.ParseCode())
                return;

            if (!options.Quiet)
                Log.EmitMessage("Processing code...");

            library.Preprocess(driver, driver.ASTContext);

            driver.SetupPasses(library);

            driver.ProcessCode();
            library.Postprocess(driver, driver.ASTContext);

            if (!options.Quiet)
                Log.EmitMessage("Generating code...");

            var outputs = driver.GenerateCode();

            foreach (var output in outputs)
            {
                foreach (var pass in driver.GeneratorOutputPasses.Passes)
                {
                    pass.Driver = driver;
                    pass.VisitGeneratorOutput(output);
                }
            }

            if (!driver.Options.DryRun)
                driver.WriteCode(outputs);

            if (driver.Options.IsCSharpGenerator)
                driver.CompileCode();
        }
        public void RegisterArchitectures(ILibrary library)
        {
            if(library == null)
                throw new ArgumentNullException("library");

            library.AddArchitecture(new TransitionArchitectures());
        }
 public void Register(ILibrary library)
 {
     RegisterEntities(library);
     RegisterArchitectures(library);
     RegisterTheorems(library);
     RegisterStructures(library);
 }
        public void RegisterStructures(ILibrary library)
        {
            if(library == null)
                throw new ArgumentNullException("library");

            TokenValue.Register(library);
        }
        public void RegisterEntities(ILibrary library)
        {
            if(library == null)
                throw new ArgumentNullException("library");

            library.AddEntity(new ArbitraryGenericEntity("|", "Transition", "PetriNet"));
        }
        public void RegisterTheorems(ILibrary library)
        {
            if(library == null)
                throw new ArgumentNullException("library");

            TransitionArchitectures.RegisterTheorems(library);
        }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    ReadOnlySignalSet squares = StdBuilder.Square(port.OutputSignals);
                    Signal one = IntegerValue.ConstantOne;
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add((one + squares[i]) * manipulatedInputs[i]);
                    return outputs;
                }));

            MathIdentifier typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
            ITheoremProvider basicProvider;
            if(!library.TryLookupTheoremType(typeId, out basicProvider))
            {
                basicProvider = Binder.GetInstance<ITransformationTheoremProvider, MathIdentifier>(typeId);
                library.AddTheoremType(basicProvider);
            }
            ((ITransformationTheoremProvider)basicProvider).Add(
                new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    Signal[] ret = new Signal[transformedInputs.Count];
                    for(int i = 0; i < ret.Length; i++)
                        ret[i] = StdBuilder.Sine(transformedInputs[i]) / StdBuilder.Cosine(transformedInputs[i]);
                    return ret;
                }));
        }
        private void FillNetVersionSupport(FeatureTable table, ILibrary library, IEnumerable<IGrouping<string, FrameworkName>> allVersionsGrouped)
        {
            if (library.PackageId == null) {
                // this is always intentional
                foreach (var versionGroup in allVersionsGrouped) {
                    var cell = table[library, versionGroup];
                    cell.State = FeatureState.Skipped;
                    cell.DisplayValue = "n/a";
                }

                return;
            }

            var package = this.packageCache.GetPackage(library.PackageId);
            var supported = package.GetSupportedFrameworks().ToArray();

            foreach (var versionGroup in allVersionsGrouped) {
                var cell = table[library, versionGroup];
                if (versionGroup.Any(v => VersionUtility.IsCompatible(v, supported))) {
                    cell.State = FeatureState.Success;
                    cell.DisplayValue = "yes";
                }
                else {
                    cell.State = FeatureState.Concern;
                    cell.DisplayValue = "no";
                }
            }
        }
예제 #15
0
 public ILibrary AddAllInLibrary(ILibrary library)
 {
     foreach (IModule module in library.Modules)
     {
         AddModule(module);
     }
     return library;
 }
예제 #16
0
        public IntPtr BuildModernContext(ContextCreationParameters contextParameters, ILibrary library, IContext sharedContext, IntPtr legacyContextHandle)
        {
            if (!_wgl.wglMakeCurrent((IntPtr)contextParameters.Device, legacyContextHandle))
                throw new ContextCreationException("Unable to make temporary context current.", contextParameters);


            var choosePixelFormat = library.GetProcedure<wglChoosePixelFormatARB>("wglChoosePixelFormatARB");
            var createContext = library.GetProcedure<wglCreateContextAttribsARB>("wglCreateContextAttribsARB");

            if (choosePixelFormat == null)
                throw new MissingEntryPointException("wglChoosePixelFormatARB", library);

            if (createContext == null)
                throw new MissingEntryPointException("wglCreateContextAttribsARB", library);

            var formats = new int[1];
            var numFormats = new uint[1];

            var pixelFormatParameters = new[]
                    {
                        WindowsContext.WGLPixelFormatConstants.WGL_DRAW_TO_WINDOW_ARB, (int) GLboolean.True,
                        WindowsContext.WGLPixelFormatConstants.WGL_SUPPORT_OPENGL_ARB, (int) GLboolean.True,
                        WindowsContext.WGLPixelFormatConstants.WGL_DOUBLE_BUFFER_ARB, (int) GLboolean.True,
                        WindowsContext.WGLPixelFormatConstants.WGL_PIXEL_TYPE_ARB, WindowsContext.WGLPixelFormatConstants.WGL_TYPE_RGBA_ARB,
                        WindowsContext.WGLPixelFormatConstants.WGL_COLOR_BITS_ARB, contextParameters.ColorBits.HasValue ? contextParameters.ColorBits.Value : 32,
                        WindowsContext.WGLPixelFormatConstants.WGL_DEPTH_BITS_ARB, contextParameters.DepthBits.HasValue ? contextParameters.DepthBits.Value : 24,
                        WindowsContext.WGLPixelFormatConstants.WGL_STENCIL_BITS_ARB, contextParameters.StencilBits.HasValue ? contextParameters.StencilBits.Value : 8,
                        WindowsContext.WGLPixelFormatConstants.WGL_SAMPLE_BUFFERS_ARB, 1,
                        WindowsContext.WGLPixelFormatConstants.WGL_SAMPLES_ARB, 4,
                        0 //End 
                    };

            if (!choosePixelFormat((IntPtr)contextParameters.Device, pixelFormatParameters, null, 1, formats, numFormats))
            {
                throw new ContextCreationException("Unable to choose pixel format.", contextParameters);
            }

            var finalContext = createContext((IntPtr)contextParameters.Device, sharedContext != null ? sharedContext.Handle : IntPtr.Zero, new[]
            {
                (int)WGLContextAttributes.MajorVersion, contextParameters.MajorVersion.HasValue ? contextParameters.MajorVersion.Value : 3,
                (int)WGLContextAttributes.MinorVersion, contextParameters.MinorVersion.HasValue ? contextParameters.MinorVersion.Value : 2,
                (int)WGLContextAttributes.Flags, 0,
                (int)WGLContextAttributes.ProfileMask, (int)WGLContextProfileMask.CoreProfileBit,
                0
            }
            );

            if(finalContext == IntPtr.Zero)
                throw new ContextCreationException("Unable to create OpenGL 3.0 context.", contextParameters);



            return finalContext;
        }
예제 #17
0
        private static MathContext CreateGlobalContext()
        {
            var modules = new ILibrary[]
                {
                    new MathLib()
                };

            var context = new MathContext();
            foreach (var module in modules)
                module.Register(context);
            return context;
        }
 public static void RegisterTheorems(ILibrary library)
 {
     Analysis.DerivativeTransformation.Provider.Add(
         new Analysis.DerivativeTransformation(_entityId,
         delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
         {
             SignalSet outputs = new SignalSet();
             for(int i = 0; i < manipulatedInputs.Count; i++)
                 outputs.Add(manipulatedInputs[i] / port.InputSignals[i]);
             return outputs;
         }));
 }
예제 #19
0
        public ParserScanner(TextReader reader, IMathSystem system)
        {
            if(system == null)
                throw new ArgumentNullException("system");
            if(reader == null)
                throw new ArgumentNullException("reader");

            tokenizer = new ParserMarker(reader);
            this.system = system;
            this.library = Service<ILibrary>.Instance;
            this.builder = Service<IBuilder>.Instance;
        }
예제 #20
0
        public MediaFinder(ILibrary lib, DirectoryInfo[] music)
        {
            _lib = lib;
            _musicDir = music;
            _watchers = new FileSystemWatcher[music.Length];
            //Create file watchers that monitor for new files.
            for (int i = 0; i < _watchers.Length; i++)
            {
                _watchers[i] = new FileSystemWatcher(music[i].FullName);
                _watchers[i].Created += new FileSystemEventHandler(MediaFinder_Music_Created);

            }
        }
예제 #21
0
        private IDictionary<string, object> GetAllFeatureData(ILibrary library, IEnumerable<FeatureTable> tables)
        {
            var featuresByName = tables.Where(t => t.Key != MetadataKeys.GeneralInfoTable && t.Key != MetadataKeys.NetFxSupportTable)
                                       .SelectMany(t => t.Features.Select(f => this.GetSingleFeatureData(f, t[library, f])))
                                       .GroupBy(p => p.Key)
                                       .ToArray();

            var duplicate = featuresByName.FirstOrDefault(g => g.Count() > 1);
            if (duplicate != null)
                throw new Exception("Feature name " + duplicate.Key + " was used more than once.");

            return featuresByName.ToDictionary(p => p.Key, p => p.Single().Value);
        }
 public static void RegisterTheorems(ILibrary library)
 {
     Analysis.DerivativeTransformation.Provider.Add(
         new Analysis.DerivativeTransformation(_entityId,
         delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
         {
             Signal[] outputs = new Signal[manipulatedInputs.Count];
             ReadOnlySignalSet sines = StdBuilder.Sine(port.InputSignals);
             for(int i = 0; i < outputs.Length; i++)
                 outputs[i] = sines[i] * manipulatedInputs[i];
             return StdBuilder.Negate(outputs);
         }));
 }
        public void RegisterArchitectures(ILibrary library)
        {
            if(library == null)
                throw new ArgumentNullException("library");

            #region Arithmetics
            library.AddArchitecture(new Arithmetics.AdditionArchitectures());
            library.AddArchitecture(new Arithmetics.SubtractionArchitectures());
            library.AddArchitecture(new Arithmetics.MultiplicationArchitectures());
            library.AddArchitecture(new Arithmetics.DivisionArchitectures());
            library.AddArchitecture(new Arithmetics.NegateArchitectures());
            library.AddArchitecture(new Arithmetics.InvertArchitectures());
            library.AddArchitecture(new Arithmetics.AbsoluteArchitectures());
            library.AddArchitecture(new Arithmetics.ExponentialArchitectures());
            library.AddArchitecture(new Arithmetics.NaturalLogarithmArchitectures());
            library.AddArchitecture(new Arithmetics.SquareArchitectures());
            library.AddArchitecture(new Arithmetics.PowerArchitectures());
            #endregion
            #region Trigonometry
            library.AddArchitecture(new Trigonometry.SineArchitectures());
            library.AddArchitecture(new Trigonometry.CosineArchitectures());
            library.AddArchitecture(new Trigonometry.TangentArchitectures());
            library.AddArchitecture(new Trigonometry.CotangentArchitectures());
            library.AddArchitecture(new Trigonometry.SecantArchitectures());
            library.AddArchitecture(new Trigonometry.CosecantArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicSineArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicCosineArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicTangentArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicCotangentArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicSecantArchitectures());
            library.AddArchitecture(new Trigonometry.HyperbolicCosecantArchitectures());
            #endregion
            #region Logic
            library.AddArchitecture(new Logic.AndArchitectures());
            library.AddArchitecture(new Logic.NandArchitectures());
            library.AddArchitecture(new Logic.OrArchitectures());
            library.AddArchitecture(new Logic.NorArchitectures());
            library.AddArchitecture(new Logic.XorArchitectures());
            library.AddArchitecture(new Logic.XnorArchitectures());
            library.AddArchitecture(new Logic.NotArchitectures());
            #endregion
            #region Algebra & Analysis
            library.AddArchitecture(new Analysis.AlgebraicDerivativeArchitecture());
            library.AddArchitecture(new Algebra.AutoSimplifyArchitecture());
            #endregion
            #region Flow
            library.AddArchitecture(new Flow.TransportArchitecture());
            library.AddArchitecture(new Flow.SyncArchitecture());
            library.AddArchitecture(new Flow.ClockArchitecture());
            #endregion
        }
예제 #24
0
        public LexerScanner(TextReader reader)
        {
            if(reader == null)
                throw new ArgumentNullException("reader");

            this.lexer = new LexerMarker(reader);
            this.library = Service<ILibrary>.Instance;

            this.executorCharacter = Config.ExecutorCharacter;
            this.seperatorCharacter = Config.SeparatorCharacter;
            this.listEncapsulation = Config.ListEncapsulation;
            this.vectorEncapsulation = Config.VectorEncapsulation;
            this.setEncapsulation = Config.SetEncapsulation;
            this.scalarEncapsulation = Config.ScalarEncapsulation;
            this.literalEncapsulation = Config.LiteralEncapsulation;
        }
예제 #25
0
		/// <summary>
		/// Solves the boggle board!
		/// </summary>
		/// <param name="board">Board to solve.</param>
		/// <param name="library">Dictionary of words.</param>
		public Result Solve(IBoard board, ILibrary library)
		{
			var result = new Result();
			result.Words = new HashSet<string>();
			var start = Environment.TickCount;

			var tasks = new List<Task>();

			for (int i = 0; i < board.Width; i++)
			{
				for (int j = 0; j < board.Height; j++)
				{
					// Capture i/j values (will fail without since i/j change too fast before the thread runs)
					var state = new ThreadState(i, j);

					// note: I'm sure this is a lot of memory spawning a bajillion tasks but it was easy.
					tasks.Add(Task.Run(() =>
					{

						var path = new WordPath(board.Grid[state.X][state.Y], state.X, state.Y);
						var myWords = Worker(
							state.X, 
							state.Y, 
							path, 
							1, 
							board, 
							library.Books[board.Grid[state.X][state.Y]], 
							new HashSet<string>());

						// Merge results (queue up instead and have the main thread do the work?
						// This seems like a bottle neck but since tasks are not reused it might not matter.
						lock (_mergeResultsLock)
						{
							result.Words.UnionWith(myWords);
						}
					
					}));
				}
			}

			Task.WaitAll(tasks.ToArray());

			var stop = Environment.TickCount;
			result.ElapsedMS = stop - start;

			return result;
		}
예제 #26
0
        private void LibraryAdded(object sender, ILibrary library)
        {
            MenuItem libraryMenuItem = new MenuItem();
            libraryMenuItem.Header = library.GetName();

            foreach (Type node in library.GetNodeTypes())
            {
                MenuItem libraryNodeItem = new MenuItem();
                libraryNodeItem.Header = node.Name;

                nodeTypes[libraryNodeItem] = node;
                libraryNodeItem.Click += new RoutedEventHandler(libraryNodeItem_Click);

                libraryMenuItem.Items.Add(libraryNodeItem);
            }

            Libraries.Items.Add(libraryMenuItem);
        }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    return new SignalSet(manipulatedInputs);
                }));

            Algebra.AutoSimplifyTransformation.Provider.Add(
                new Algebra.AutoSimplifyTransformation(_entityId,
                delegate(Port port)
                {
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    return new SignalSet(manipulatedInputs);
                }));
        }
 public static void RegisterTheorems(ILibrary library)
 {
     Algebra.AutoSimplifyTransformation.Provider.Add(
         new Algebra.AutoSimplifyTransformation(new MathIdentifier("GenericMathOpAutoSimplify", "Std"),
         delegate()
         {
             return new Pattern(new ArchitectureCondition(delegate(IArchitecture a) { return a.IsMathematicalOperator; }));
         },
         delegate(Port port)
         {
             return ManipulationPlan.DoAlter;
         },
         delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
         {
             if(hasManipulatedInputs)
                 port = port.Entity.InstantiatePort(manipulatedInputs);
             if(port.HasArchitectureLink && port.CurrentArchitecture.IsMathematicalOperator)
                 return port.CurrentArchitecture.ExecuteMathematicalOperator();
             else
                 return port.OutputSignals;
         }));
 }
        void LibraryAdded(object sender, ILibrary library)
        {
            Menu libraryMenu = new Menu();
            ToolBar.SetOverflowMode(libraryMenu, OverflowMode.AsNeeded);
            libraryMenu.Background = new SolidColorBrush(Color.FromRgb((byte)0xBC, (byte)0xC7, (byte)0xD8));
            Items.Add(libraryMenu);

            MenuItem libraryMenuItem = new MenuItem();
            libraryMenuItem.Header = library.GetName();
            libraryMenu.Items.Add(libraryMenuItem);

            foreach (Type node in library.GetNodeTypes())
            {
                MenuItem libraryNodeItem = new MenuItem();
                libraryNodeItem.Header = node.Name;

                nodeTypes[libraryNodeItem] = node;
                libraryNodeItem.Click += new RoutedEventHandler(libraryNodeItem_Click);
                
                libraryMenuItem.Items.Add(libraryNodeItem);
            }
        }
예제 #30
0
        private void CheckCondensedFormatIO(ILibrary library)
        {
            var io = new LibraryIO(new CondensedFormat());

            CheckIO(library, io);
        }
예제 #31
0
 /// <param name="library"></param>
 public CoreCommand(ILibrary library)
 {
     this.library = library;
 }
        private async Task InstallPackageAsync()
        {
            try
            {
                bool isLibraryInstallationStateValid = await IsLibraryInstallationStateValidAsync().ConfigureAwait(false);

                if (isLibraryInstallationStateValid)
                {
                    ILibrary selectedPackage = SelectedPackage;
                    InstallPackageCommand.CanExecute(null);
                    Manifest manifest = await Manifest.FromFileAsync(_configFileName, _deps, CancellationToken.None).ConfigureAwait(false);

                    string targetPath = _targetPath;

                    if (!string.IsNullOrEmpty(_configFileName))
                    {
                        Uri configContainerUri = new Uri(_configFileName, UriKind.Absolute);
                        Uri targetUri          = new Uri(targetPath, UriKind.Absolute);
                        targetPath = configContainerUri.MakeRelativeUri(targetUri).ToString();
                    }

                    if (String.IsNullOrEmpty(manifest.Version))
                    {
                        manifest.Version = Manifest.SupportedVersions.Max().ToString();
                    }

                    (string name, string version) = LibraryIdToNameAndVersionConverter.Instance.GetLibraryNameAndVersion(LibraryId, SelectedProvider.Id);
                    LibraryInstallationState libraryInstallationState = new LibraryInstallationState
                    {
                        Name            = name,
                        Version         = version,
                        ProviderId      = selectedPackage.ProviderId,
                        DestinationPath = TargetLocationViewModel.SearchText,
                    };

                    _isInstalling = true;

                    // When "Include all files" option is checked, we don't want to write out the files to libman.json.
                    // We will only list the files when user chose to install specific files.
                    if (LibraryFilesToInstall == FileSelectionType.ChooseSpecificFilesToInstall)
                    {
                        libraryInstallationState.Files = SelectedFiles.ToList();
                    }

                    manifest.AddLibrary(libraryInstallationState);

                    await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    if (!File.Exists(_configFileName))
                    {
                        await manifest.SaveAsync(_configFileName, CancellationToken.None);

                        if (_project != null)
                        {
                            await _project.AddFileToProjectAsync(_configFileName);
                        }
                    }

                    RunningDocumentTable rdt = new RunningDocumentTable(Shell.ServiceProvider.GlobalProvider);
                    string configFilePath    = Path.GetFullPath(_configFileName);

                    IVsTextBuffer textBuffer = rdt.FindDocument(configFilePath) as IVsTextBuffer;

                    // The file isn't open. So we'll write to disk directly
                    if (textBuffer == null)
                    {
                        manifest.AddLibrary(libraryInstallationState);

                        await manifest.SaveAsync(_configFileName, CancellationToken.None).ConfigureAwait(false);

                        Telemetry.TrackUserTask("Invoke-RestoreFromAddClientLibrariesDialog");
                        await _libraryCommandService.RestoreAsync(_configFileName, CancellationToken.None).ConfigureAwait(false);
                    }
                    else
                    {
                        // libman.json file is open, so we will write to the textBuffer.
                        InsertIntoTextBuffer(textBuffer, libraryInstallationState, manifest);

                        // Save manifest file so we can restore library files.
                        rdt.SaveFileIfDirty(configFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(nameof(InstallPackageAsync), ex);
            }
        }
예제 #33
0
 /// <summary>
 /// Creates an instance of an exception describing a missing entry point.
 /// </summary>
 /// <param name="entryPoint"></param>
 /// <param name="library"></param>
 public MissingEntryPointException(string entryPoint, ILibrary library)
     : base(string.Format("The entry point '{0}' could not be found in the library '{1}'.", entryPoint, library != null ? library.Name : null))
 {
     EntryPoint  = entryPoint;
     LibraryName = library != null ? library.Name : null;
 }
예제 #34
0
 public Transformer()
 {
     _manipulator = new Manipulator();
     _library     = Service <ILibrary> .Instance;
 }
예제 #35
0
 public LibraryService(ILibrary library)
 {
     _library = library;
 }
예제 #36
0
        private void CheckReadableFormatIO(ILibrary library)
        {
            var io = new LibraryIO(new ReadableFormat());

            CheckIO(library, io);
        }
예제 #37
0
 public override IEnumerable <BookViewModel> FindBook(ILibrary library)
 {
     return(library.BookSource);
 }
예제 #38
0
 public override IEnumerable <BookViewModel> FindBook(ILibrary library)
 {
     return(library.BookSource.Where(b => b.ByteSize == null));
 }
 public SettingsViewModel (ILibrary library) {
     this.library = library;
     this.Header = "Settings";
     this.Position = Position.Right;
 }
예제 #40
0
 public abstract IEnumerable <BookViewModel> FindBook(ILibrary library);