Exemple #1
0
        public void SystemToExpressionTest()
        {
            Project    p  = new Project();
            MathSystem s1 = p.CurrentSystem;

            // BUILD SYSTEM 1: sin(x^2)*2
            Signal x = Binder.CreateSignal(); x.Label = "x";

            Std.ConstrainAlwaysReal(x);
            Signal x2      = StdBuilder.Square(x); x2.Label = "x2";
            Signal sinx2   = StdBuilder.Sine(x2); sinx2.Label = "sinx2";
            Signal sinx2t2 = sinx2 * IntegerValue.ConstantTwo;

            s1.AddSignalTree(sinx2t2, true, true);

            // EVALUATE SYSTEM 1 FOR x=1.5
            x.PostNewValue(new RealValue(1.5));
            p.SimulateInstant();
            Assert.AreEqual(0, s1.BusCount, "A0");
            Assert.AreEqual(5, s1.SignalCount, "A1");
            Assert.AreEqual(3, s1.PortCount, "A2");
            Assert.AreEqual("Std.Real(1.55614639377584)", sinx2t2.Value.ToString(), "A3");

            // SERIALIZE SYSTEM 1 TO EXPRESSION
            ExpressionWriter writer = new ExpressionWriter();
            SystemReader     reader = new SystemReader(writer);

            reader.ReadSystem(s1);
            string expr = writer.WrittenExpressions.Dequeue();

            Console.WriteLine(expr);

            // ....
        }
Exemple #2
0
        private void LoadSystem()
        {
            string path = EditorUtility.OpenFilePanel("Load system from c# code", Application.dataPath, "cs");

            if (!File.Exists(path))
            {
                return;
            }

            var fileData = SystemReader.Read(path);

            if (fileData == null)
            {
                EditorUtility.DisplayDialog("Invalid file", "Can not load selected file", "OK");
                return;
            }

            var newNode = SystemNode.FromFile(Target, fileData);

            if (newNode == null)
            {
                EditorUtility.DisplayDialog("Invalid file", "Selected file is already loaded", "OK");
                return;
            }

            SetupNewNode(newNode);
        }
Exemple #3
0
 /// <summary>Create a repository using the local file system.</summary>
 /// <remarks>Create a repository using the local file system.</remarks>
 /// <param name="options">description of the repository's important paths.</param>
 /// <exception cref="System.IO.IOException">
 /// the user configuration file or repository configuration file
 /// cannot be accessed.
 /// </exception>
 protected internal FileRepository(BaseRepositoryBuilder options) : base(options)
 {
     systemConfig = SystemReader.GetInstance().OpenSystemConfig(null, FileSystem);
     userConfig   = SystemReader.GetInstance().OpenUserConfig(systemConfig, FileSystem);
     repoConfig   = new FileBasedConfig(userConfig, FileSystem.Resolve(Directory, Constants
                                                                       .CONFIG), FileSystem);
     LoadSystemConfig();
     LoadUserConfig();
     LoadRepoConfig();
     repoConfig.AddChangeListener(new _ConfigChangedListener_171(this));
     refs           = new RefDirectory(this);
     objectDatabase = new ObjectDirectory(repoConfig, options.GetObjectDirectory(), options
                                          .GetAlternateObjectDirectories(), FileSystem);
     //
     //
     //
     if (objectDatabase.Exists())
     {
         long repositoryFormatVersion = ((FileBasedConfig)GetConfig()).GetLong(ConfigConstants
                                                                               .CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, 0);
         if (repositoryFormatVersion > 0)
         {
             throw new IOException(MessageFormat.Format(JGitText.Get().unknownRepositoryFormat2
                                                        , Sharpen.Extensions.ValueOf(repositoryFormatVersion)));
         }
     }
     if (!IsBare)
     {
         snapshot = FileSnapshot.Save(GetIndexFile());
     }
 }
Exemple #4
0
        public virtual void setUp()
        {
            recursiveDelete(testName() + " (SetUp)", trash, false, true);

            mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(new FileInfo(Path.Combine(trash.FullName, "usergitconfig")));
            SystemReader.setInstance(mockSystemReader);

            long now = mockSystemReader.getCurrentTime();
            int  tz  = mockSystemReader.getTimezone(now);

            author = new PersonIdent("J. Author", "*****@*****.**");
            author = new PersonIdent(author, now, tz);

            committer = new PersonIdent("J. Committer", "*****@*****.**");
            committer = new PersonIdent(committer, now, tz);

            WindowCacheConfig c = new WindowCacheConfig();

            c.PackedGitLimit      = (128 * WindowCacheConfig.Kb);
            c.PackedGitWindowSize = (8 * WindowCacheConfig.Kb);
            c.PackedGitMMAP       = (useMMAP);
            c.DeltaBaseCacheLimit = (8 * WindowCacheConfig.Kb);
            WindowCache.reconfigure(c);
        }
Exemple #5
0
        public static bool IsRunningOn(AssertedPlatform assertedPlatform)
        {
            SystemReader systemReader = SystemReader.getInstance();

            bool isRunningOnUnknownOS = (systemReader.getOperatingSystem() == PlatformType.Unknown);

            if (isRunningOnUnknownOS)
            {
                return(false);
            }


            bool isRunningOnWindows = (systemReader.getOperatingSystem() == PlatformType.Windows);

            if (isRunningOnWindows && assertedPlatform == AssertedPlatform.Windows)
            {
                return(true);
            }

            if (!isRunningOnWindows && assertedPlatform == AssertedPlatform.Mono)
            {
                return(true);
            }

            return(false);
        }
Exemple #6
0
        /// <summary>
        /// Returns the system-wide path for application settings based on OS
        /// </summary>
        /// <returns></returns>
        public static string getCommonAppDataPath()
        {
            string       path  = string.Empty;
            PlatformType ptype = SystemReader.getInstance().getOperatingSystem();

            switch (ptype)
            {
            case PlatformType.Windows:
                path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                break;

            case PlatformType.Unix:
                path = "~(prefix)/etc";
                break;

            case PlatformType.MacOSX:
                path = "~(prefix)/etc";
                break;

            case PlatformType.Xbox:
            default:
                throw new ArgumentException("CommonAppData support for '" + Environment.OSVersion.VersionString + " ' is not implemented.");
            }

            return(path);
        }
        protected override void OnStop()
        {
            base.OnStop();

            _jobManager.Stop();
            SLogger.Info(InstallServiceName + " Service was stopped by " + SystemReader.GetWindowsUsername() + ".");
        }
Exemple #8
0
 /// <summary>
 /// Construct a new
 /// <see cref="PersonIdent">PersonIdent</see>
 /// with current time.
 /// </summary>
 /// <param name="aName"></param>
 /// <param name="aEmailAddress"></param>
 public PersonIdent(string aName, string aEmailAddress)
 {
     name         = aName;
     emailAddress = aEmailAddress;
     when         = SystemReader.GetInstance().GetCurrentTime();
     tzOffset     = SystemReader.GetInstance().GetTimezone(when);
 }
Exemple #9
0
 /// <summary>Create a repository using the local file system.</summary>
 /// <remarks>Create a repository using the local file system.</remarks>
 /// <param name="options">description of the repository's important paths.</param>
 /// <exception cref="System.IO.IOException">
 /// the user configuration file or repository configuration file
 /// cannot be accessed.
 /// </exception>
 protected internal FileRepository(BaseRepositoryBuilder options) : base(options)
 {
     systemConfig = SystemReader.GetInstance().OpenSystemConfig(null, FileSystem);
     userConfig   = SystemReader.GetInstance().OpenUserConfig(systemConfig, FileSystem);
     repoConfig   = new FileBasedConfig(userConfig, FileSystem.Resolve(Directory, "config"
                                                                       ), FileSystem);
     //
     //
     LoadSystemConfig();
     LoadUserConfig();
     LoadRepoConfig();
     repoConfig.AddChangeListener(new _ConfigChangedListener_168(this));
     refs           = new RefDirectory(this);
     objectDatabase = new ObjectDirectory(repoConfig, options.GetObjectDirectory(), options
                                          .GetAlternateObjectDirectories(), FileSystem);
     //
     //
     //
     if (objectDatabase.Exists())
     {
         string repositoryFormatVersion = ((FileBasedConfig)GetConfig()).GetString(ConfigConstants
                                                                                   .CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION);
         if (!"0".Equals(repositoryFormatVersion))
         {
             throw new IOException(MessageFormat.Format(JGitText.Get().unknownRepositoryFormat2
                                                        , repositoryFormatVersion));
         }
     }
 }
Exemple #10
0
        private void writePack(IDictionary <string, RemoteRefUpdate> refUpdates, ProgressMonitor monitor)
        {
            PackWriter      writer        = new PackWriter(local, monitor);
            List <ObjectId> remoteObjects = new List <ObjectId>(Refs.Count);
            List <ObjectId> newObjects    = new List <ObjectId>(refUpdates.Count);

            foreach (Ref r in Refs)
            {
                remoteObjects.Add(r.ObjectId);
            }

            remoteObjects.AddRange(additionalHaves);
            foreach (RemoteRefUpdate r in refUpdates.Values)
            {
                if (!ObjectId.ZeroId.Equals(r.NewObjectId))
                {
                    newObjects.Add(r.NewObjectId);
                }
            }

            writer.Thin = _thinPack;
            writer.DeltaBaseAsOffset = _capableOfsDelta;
            writer.preparePack(newObjects, remoteObjects);
            long start = SystemReader.getInstance().getCurrentTime();

            writer.writePack(outStream);
            packTransferTime = SystemReader.getInstance().getCurrentTime() - start;
        }
Exemple #11
0
        /// <summary>
        /// Returns the system-wide path for application settings based on OS
        /// </summary>
        /// <returns></returns>
        public static DirectoryInfo systemHomeImpl()
        {
            string       path  = string.Empty;
            PlatformType ptype = SystemReader.getInstance().getOperatingSystem();

            switch (ptype)
            {
            case PlatformType.Windows:
                path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GitSharp");
                break;

            case PlatformType.Unix:
                path = "~(prefix)/etc";
                break;

            case PlatformType.MacOSX:
                path = "~(prefix)/etc";
                break;

            case PlatformType.Xbox:
            default:
                throw new ArgumentException("SystemHomeImpl support for '" + Environment.OSVersion.VersionString + " ' is not implemented.");
            }

            return(new DirectoryInfo(path));
        }
Exemple #12
0
        protected override void InnerExcute(IJobExecutionContext context)
        {
            try
            {
                SLogger.Info(string.Format("{0}: Starting Push question to QnA job", JobFriendlyName));

                var lastRunTime = SystemReader.GetLastPushQnAJobRunTime();

                var lstQuestion = _qnaService.GetQnAByDate(lastRunTime);

                // call stand alone to execute QnA
                var data = new PushLatestQnA {
                    ListQuestionAndAnswers = lstQuestion.ToList()
                };

                ApiHelper.PostAsyncNoEncrypt(WebApiConstant.XoomPushQuestionStandAloneEndPoint, data).GetAwaiter().GetResult();

                SLogger.Info(string.Format("{0} : - End Push question to QnA job", JobFriendlyName));

                SystemReader.SetLastPushQnAJobRunTime(DateTime.Now);
            }
            catch (Exception ex)
            {
                SLogger.Error(string.Format("{0}: InnerExcute. Push question to QnA job", JobFriendlyName), ex);
            }
        }
        public override void Update(int completed)
        {
            if (_msg == null)
                return;

            int cmp = _lastWorked + completed;
            long now = SystemReader.getInstance().getCurrentTime();
            if (!_output && now - _taskBeganAt < 500)
                return;
            if (_totalWork == UNKNOWN)
            {
                if (now - _lastOutput >= 500)
                {
                    display(cmp, null);
                    _lastOutput = now;
                }
            }
            else
            {
                if ((cmp * 100 / _totalWork) != (_lastWorked * 100) / _totalWork || now - _lastOutput >= 500)
                {
                    display(cmp, null);
                    _lastOutput = now;
                }
            }
            _lastWorked = cmp;
            _output = true;
        }
Exemple #14
0
        public void WriteXml(XmlWriter writer)
        {
            XmlSystemWriter xwriter = new XmlSystemWriter(_context, writer);
            SystemReader    xreader = new SystemReader(xwriter);

            xreader.ReadSystem(this);
            writer.Flush();
        }
        protected override void ConfigureVersionControlSystem()
        {
            var mockSystemReader = new MockSystemReader(SystemReader.GetInstance());

            SystemReader.SetInstance(mockSystemReader);

            For <IVersionControlSystem>().Use <GitVersionControlSystem>();
        }
Exemple #16
0
        public MathSystem Clone()
        {
            SystemWriter writer = new SystemWriter(_context);
            SystemReader reader = new SystemReader(writer);

            reader.ReadSystem(this);
            return(writer.WrittenSystems.Dequeue());
        }
 /// <summary>Read standard Git environment variables and configure from those.</summary>
 /// <remarks>
 /// Read standard Git environment variables and configure from those.
 /// <p>
 /// This method tries to read the standard Git environment variables, such as
 /// <code>GIT_DIR</code>
 /// and
 /// <code>GIT_WORK_TREE</code>
 /// to configure this builder
 /// instance. If a property is already set in the builder, the environment
 /// variable is not used.
 /// </remarks>
 /// <param name="sr">the SystemReader abstraction to access the environment.</param>
 /// <returns>
 ///
 /// <code>this</code>
 /// (for chaining calls).
 /// </returns>
 public virtual B ReadEnvironment(SystemReader sr)
 {
     if (GetGitDir() == null)
     {
         string val = sr.Getenv(Constants.GIT_DIR_KEY);
         if (val != null)
         {
             SetGitDir(new FilePath(val));
         }
     }
     if (GetObjectDirectory() == null)
     {
         string val = sr.Getenv(Constants.GIT_OBJECT_DIRECTORY_KEY);
         if (val != null)
         {
             SetObjectDirectory(new FilePath(val));
         }
     }
     if (GetAlternateObjectDirectories() == null)
     {
         string val = sr.Getenv(Constants.GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY);
         if (val != null)
         {
             foreach (string path in val.RegexSplit(FilePath.pathSeparator))
             {
                 AddAlternateObjectDirectory(new FilePath(path));
             }
         }
     }
     if (GetWorkTree() == null)
     {
         string val = sr.Getenv(Constants.GIT_WORK_TREE_KEY);
         if (val != null)
         {
             SetWorkTree(new FilePath(val));
         }
     }
     if (GetIndexFile() == null)
     {
         string val = sr.Getenv(Constants.GIT_INDEX_FILE_KEY);
         if (val != null)
         {
             SetIndexFile(new FilePath(val));
         }
     }
     if (ceilingDirectories == null)
     {
         string val = sr.Getenv(Constants.GIT_CEILING_DIRECTORIES_KEY);
         if (val != null)
         {
             foreach (string path in val.RegexSplit(FilePath.pathSeparator))
             {
                 AddCeilingDirectory(new FilePath(path));
             }
         }
     }
     return(Self());
 }
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            log4net.Config.XmlConfigurator.Configure();
            ConfigurationManager.RefreshSection("appSettings");

            _jobManager.Start();
            SLogger.Info(InstallServiceName + " Service was started by " + SystemReader.GetWindowsUsername() + ".");
        }
Exemple #19
0
        /// <summary>Creates new PersonIdent from config info in repository, with current time.
        ///     </summary>
        /// <remarks>
        /// Creates new PersonIdent from config info in repository, with current time.
        /// This new PersonIdent gets the info from the default committer as available
        /// from the configuration.
        /// </remarks>
        /// <param name="repo"></param>
        public PersonIdent(Repository repo)
        {
            UserConfig config = repo.GetConfig().Get(UserConfig.KEY);

            name         = config.GetCommitterName();
            emailAddress = config.GetCommitterEmail();
            when         = SystemReader.GetInstance().GetCurrentTime();
            tzOffset     = SystemReader.GetInstance().GetTimezone(when);
        }
Exemple #20
0
        public virtual void Test007_readUserConfig()
        {
            MockSystemReader mockSystemReader = new MockSystemReader();

            SystemReader.SetInstance(mockSystemReader);
            string hostname      = mockSystemReader.GetHostname();
            Config userGitConfig = mockSystemReader.OpenUserConfig(null, FS.DETECTED);
            Config localConfig   = new Config(userGitConfig);

            mockSystemReader.ClearProperties();
            string authorName;
            string authorEmail;

            // no values defined nowhere
            authorName  = localConfig.Get(UserConfig.KEY).GetAuthorName();
            authorEmail = localConfig.Get(UserConfig.KEY).GetAuthorEmail();
            NUnit.Framework.Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
            NUnit.Framework.Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname,
                                            authorEmail);
            // the system user name is defined
            mockSystemReader.SetProperty(Constants.OS_USER_NAME_KEY, "os user name");
            localConfig.Uncache(UserConfig.KEY);
            authorName = localConfig.Get(UserConfig.KEY).GetAuthorName();
            NUnit.Framework.Assert.AreEqual("os user name", authorName);
            if (hostname != null && hostname.Length != 0)
            {
                authorEmail = localConfig.Get(UserConfig.KEY).GetAuthorEmail();
                NUnit.Framework.Assert.AreEqual("os user name@" + hostname, authorEmail);
            }
            // the git environment variables are defined
            mockSystemReader.SetProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
            mockSystemReader.SetProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
            localConfig.Uncache(UserConfig.KEY);
            authorName  = localConfig.Get(UserConfig.KEY).GetAuthorName();
            authorEmail = localConfig.Get(UserConfig.KEY).GetAuthorEmail();
            NUnit.Framework.Assert.AreEqual("git author name", authorName);
            NUnit.Framework.Assert.AreEqual("author@email", authorEmail);
            // the values are defined in the global configuration
            userGitConfig.SetString("user", null, "name", "global username");
            userGitConfig.SetString("user", null, "email", "author@globalemail");
            authorName  = localConfig.Get(UserConfig.KEY).GetAuthorName();
            authorEmail = localConfig.Get(UserConfig.KEY).GetAuthorEmail();
            NUnit.Framework.Assert.AreEqual("global username", authorName);
            NUnit.Framework.Assert.AreEqual("author@globalemail", authorEmail);
            // the values are defined in the local configuration
            localConfig.SetString("user", null, "name", "local username");
            localConfig.SetString("user", null, "email", "author@localemail");
            authorName  = localConfig.Get(UserConfig.KEY).GetAuthorName();
            authorEmail = localConfig.Get(UserConfig.KEY).GetAuthorEmail();
            NUnit.Framework.Assert.AreEqual("local username", authorName);
            NUnit.Framework.Assert.AreEqual("author@localemail", authorEmail);
            authorName  = localConfig.Get(UserConfig.KEY).GetCommitterName();
            authorEmail = localConfig.Get(UserConfig.KEY).GetCommitterEmail();
            NUnit.Framework.Assert.AreEqual("local username", authorName);
            NUnit.Framework.Assert.AreEqual("author@localemail", authorEmail);
        }
Exemple #21
0
 public MockSystemReader()
 {
     init(Constants.OS_USER_NAME_KEY);
     init(Constants.GIT_AUTHOR_NAME_KEY);
     init(Constants.GIT_AUTHOR_EMAIL_KEY);
     init(Constants.GIT_COMMITTER_NAME_KEY);
     init(Constants.GIT_COMMITTER_EMAIL_KEY);
     userGitConfig   = new MockFileBasedConfig(null);
     operatingSystem = SystemReader.getInstance().getOperatingSystem();
 }
 public MockSystemReader(SystemReader initialReader)
 {
     Init(Constants.OS_USER_NAME_KEY);
     Init(Constants.GIT_AUTHOR_NAME_KEY);
     Init(Constants.GIT_AUTHOR_EMAIL_KEY);
     Init(Constants.GIT_COMMITTER_NAME_KEY);
     Init(Constants.GIT_COMMITTER_EMAIL_KEY);
     _userGitConfig       = new MockConfig(null, null);
     _systemGitConfig     = new MockConfig(null, null);
     _initialSystemReader = initialReader;
 }
Exemple #23
0
        internal static bool IsValidPath(byte[] path)
        {
            if (path.Length == 0)
            {
                return(false);
            }
            // empty path is not permitted.
            bool componentHasChars = false;

            foreach (byte c in path)
            {
                switch (c)
                {
                case 0:
                {
                    return(false);
                }

                case (byte)('/'):
                {
                    // NUL is never allowed within the path.
                    if (componentHasChars)
                    {
                        componentHasChars = false;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case (byte)('\\'):
                case (byte)(':'):
                {
                    // Tree's never have a backslash in them, not even on Windows
                    // but even there we regard it as an invalid path
                    if (SystemReader.GetInstance().IsWindows())
                    {
                        return(false);
                    }
                    goto default;
                }

                default:
                {
                    //$FALL-THROUGH$
                    componentHasChars = true;
                    break;
                }
                }
            }
            return(componentHasChars);
        }
Exemple #24
0
 public MockSystemReader(SystemReader initialReader)
 {
     Init(Constants.OS_USER_NAME_KEY);
     Init(Constants.GIT_AUTHOR_NAME_KEY);
     Init(Constants.GIT_AUTHOR_EMAIL_KEY);
     Init(Constants.GIT_COMMITTER_NAME_KEY);
     Init(Constants.GIT_COMMITTER_EMAIL_KEY);
     SetProperty("jgit.fs.debug", false.ToString());             //bug #72646. The value is required in case of Cygwin is installed
     _userGitConfig       = new MockConfig(null, null);
     _systemGitConfig     = new MockConfig(null, null);
     _initialSystemReader = initialReader;
 }
Exemple #25
0
        /// <summary>
        /// Create a new Git repository initializing the necessary files and
        /// directories.
        /// </summary>
        /// <remarks>
        /// Create a new Git repository initializing the necessary files and
        /// directories.
        /// </remarks>
        /// <param name="bare">if true, a bare repository is created.</param>
        /// <exception cref="System.IO.IOException">in case of IO problem</exception>
        public override void Create(bool bare)
        {
            FileBasedConfig cfg = ((FileBasedConfig)GetConfig());

            if (cfg.GetFile().Exists())
            {
                throw new InvalidOperationException(MessageFormat.Format(JGitText.Get().repositoryAlreadyExists
                                                                         , Directory));
            }
            FileUtils.Mkdirs(Directory, true);
            refs.Create();
            objectDatabase.Create();
            FileUtils.Mkdir(new FilePath(Directory, "branches"));
            FileUtils.Mkdir(new FilePath(Directory, "hooks"));
            RefUpdate head = UpdateRef(Constants.HEAD);

            head.DisableRefLog();
            head.Link(Constants.R_HEADS + Constants.MASTER);
            bool fileMode;

            if (FileSystem.SupportsExecute())
            {
                FilePath tmp = FilePath.CreateTempFile("try", "execute", Directory);
                FileSystem.SetExecute(tmp, true);
                bool on = FileSystem.CanExecute(tmp);
                FileSystem.SetExecute(tmp, false);
                bool off = FileSystem.CanExecute(tmp);
                FileUtils.Delete(tmp);
                fileMode = on && !off;
            }
            else
            {
                fileMode = false;
            }
            cfg.SetInt(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION
                       , 0);
            cfg.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_FILEMODE
                           , fileMode);
            if (bare)
            {
                cfg.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_BARE
                               , true);
            }
            cfg.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES
                           , !bare);
            if (SystemReader.GetInstance().IsMacOS())
            {
                // Java has no other way
                cfg.SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_PRECOMPOSEUNICODE
                               , true);
            }
            cfg.Save();
        }
Exemple #26
0
        public void WriteXml(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            XmlSystemWriter xwriter = new XmlSystemWriter(writer);
            SystemReader    xreader = new SystemReader(xwriter);

            xreader.ReadSystem(this);
            writer.Flush();
        }
Exemple #27
0
        public void SystemToSystemCloneTest()
        {
            Project    p  = new Project();
            MathSystem s1 = p.CurrentSystem;

            // BUILD SYSTEM 1: sin(x^2)
            Signal x = Binder.CreateSignal(); x.Label = "x";

            Std.ConstrainAlwaysReal(x);
            Signal x2      = StdBuilder.Square(x); x2.Label = "x2";
            Signal sinx2   = StdBuilder.Sine(x2); sinx2.Label = "sinx2";
            Signal sinx2t2 = sinx2 * IntegerValue.ConstantTwo;

            s1.AddSignalTree(sinx2t2, true, true);

            // EVALUATE SYSTEM 1 FOR x=1.5
            x.PostNewValue(new RealValue(1.5));
            p.SimulateInstant();
            Assert.AreEqual(0, s1.BusCount, "A0");
            Assert.AreEqual(5, s1.SignalCount, "A1");
            Assert.AreEqual(3, s1.PortCount, "A2");
            Assert.AreEqual("Std.Real(1.55614639377584)", sinx2t2.Value.ToString(), "A3");

            // CLONE SYSTEM 1 TO SYSTEM 2

            /*
             * HINT: would be simpler to just call:
             * MathSystem s2 = s1.Clone();
             */
            SystemWriter writer = new SystemWriter();
            SystemReader reader = new SystemReader(writer);

            reader.ReadSystem(s1);
            IMathSystem s2 = writer.WrittenSystems.Dequeue();

            Assert.AreEqual(0, s2.BusCount, "B0");
            Assert.AreEqual(5, s2.SignalCount, "B1");
            Assert.AreEqual(3, s2.PortCount, "B2");
            Assert.AreEqual("Std.Real(1.55614639377584)", s2.GetOutput(0).Value.ToString(), "B3");

            // EVALUATE SYSTEM 2 FOR x=2.5
            s2.GetInput(0).PostNewValue(new RealValue(2.5));
            p.SimulateInstant();
            Assert.AreEqual("Std.Real(-0.0663584330951136)", s2.GetOutput(0).Value.ToString(), "C0");

            // CHECK SYSTEM 1 STILL ON x=1.5
            Assert.AreEqual("Std.Real(1.5)", x.Value.ToString(), "D0");
            Assert.AreEqual("Std.Real(1.55614639377584)", sinx2t2.Value.ToString(), "D1");
        }
Exemple #28
0
        public PluginRegistry()
        {
            For <ICustomPluginSpecifyMessageHandlerOrdering>().Singleton().Use
            <MashupManagerPluginSpecifyMessageHandlerOrdering>();
            For <IMashupInfoRepository>().Use <MashupInfoRepository>();
            For <ISingleProfile>().Singleton().Use <SingleProfile>();
            For <IMashupScriptStorage>().Use <MashupScriptStorage>();
            For <IMashupLocalFolder>().Use <MashupLocalFolder>();
            For <ILibrary>().Use <Library>();
            For <ILibraryLocalFolder>().Use <LibraryLocalFolder>();
            For <ILibraryRepositoryFactory>().Use <LibraryRepositoryFactory>();
            For <ILibraryRepositorySynchronizer>().Singleton().Use <LibraryRepositorySynchronizer>();
            For <ILibraryRepositoryConfigStorage>().Use <LibraryRepositoryConfigStorage>();
            For <IMashupLoader>().Use <MashupLoader>();

            SystemReader.SetInstance(new MockSystemReader(SystemReader.GetInstance()));
        }
Exemple #29
0
            /// <exception cref="NGit.Errors.TransportException"></exception>
            public virtual SystemProcess Exec(string command, int timeout)
            {
                string         ssh   = SystemReader.GetInstance().Getenv("GIT_SSH");
                bool           putty = ssh.ToLower().Contains("plink");
                IList <string> args  = new AList <string>();

                args.AddItem(ssh);
                if (putty && !ssh.ToLower().Contains("tortoiseplink"))
                {
                    args.AddItem("-batch");
                }
                if (0 < this._enclosing.GetURI().GetPort())
                {
                    args.AddItem(putty ? "-P" : "-p");
                    args.AddItem(this._enclosing.GetURI().GetPort().ToString());
                }
                if (this._enclosing.GetURI().GetUser() != null)
                {
                    args.AddItem(this._enclosing.GetURI().GetUser() + "@" + this._enclosing.GetURI().
                                 GetHost());
                }
                else
                {
                    args.AddItem(this._enclosing.GetURI().GetHost());
                }
                args.AddItem(command);
                ProcessStartInfo pb = new ProcessStartInfo();

                pb.SetCommand(args);
                if (this._enclosing.local.Directory != null)
                {
                    pb.EnvironmentVariables.Put(Constants.GIT_DIR_KEY, this._enclosing.local.Directory
                                                .GetPath());
                }
                try
                {
                    return(pb.Start());
                }
                catch (IOException err)
                {
                    throw new TransportException(err.Message, err);
                }
            }
Exemple #30
0
        public static string getAppStorePrefix()
        {
            string       prefix = string.Empty;
            PlatformType ptype  = SystemReader.getInstance().getOperatingSystem();

            switch (ptype)
            {
            case PlatformType.Windows:
                prefix = "GitSharp";
                break;

            case PlatformType.Unix:
            case PlatformType.MacOSX:
            case PlatformType.Xbox:
            default:
                break;
            }

            return(prefix);
        }
Exemple #31
0
 /**
  * @param newReader
  *            the new instance to use when accessing properties.
  */
 public static void setInstance(SystemReader newReader)
 {
     _instance = newReader;
 }