示例#1
0
        public void ContentHandlerGetClassesTest()
        {
            var classCollection = ContentHandler.ClassesIn("RestTests.dll");

            Assert.IsTrue(classCollection.Contains("RestTests.FewTypes"));
            Assert.IsTrue(classCollection.Contains("RestTests.ManyTypes"));
        }
示例#2
0
        public void SetUp()
        {
            engine = new Fakes.FakeEngine(new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart), typeof(Fakes.FakeNodeAdapter) });
            //engine.Resolve<Fakes.FakeNodeAdapter>().Engine = engine;
            handler = new ContentHandler(engine);
            context = new Fakes.FakeWebContextWrapper();
            context.HttpContext.User = SecurityUtilities.CreatePrincipal("Admin");

            startPage = new ContentHandlerTestsPage {
                Title = "Start page"
            };
            engine.Persister.Save(startPage);
            page = new ContentHandlerTestsPage {
                Title = "Page in question"
            };
            page.AddTo(startPage);
            engine.Persister.Save(page);

            engine.AddComponentInstance <IWebContext>(context);
            engine.AddComponentInstance <IUrlParser>(new Fakes.FakeUrlParser(startPage: startPage));
            var persister         = engine.Persister;
            var activator         = engine.Resolve <ContentActivator>();
            var versionRepository = TestSupport.CreateVersionRepository(ref persister, ref activator, new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart) });

            engine.AddComponentInstance <ContentVersionRepository>(versionRepository);
            engine.AddComponentInstance <VersionManager>(versionManager = TestSupport.SetupVersionManager(engine.Persister, versionRepository));
            (engine.Resolve <IContentAdapterProvider>() as N2.Plugin.IAutoStart).Start();
            engine.Resolve <IContentAdapterProvider>().ResolveAdapter <N2.Edit.NodeAdapter>(typeof(ContentItem)).Engine = engine;
            engine.AddComponentInstance(new HtmlSanitizer(new N2.Configuration.HostSection()));
            engine.AddComponentInstance <IEditUrlManager>(new FakeEditUrlManager());
            engine.AddComponentInstance(new ConfigurationManagerWrapper());
            engine.AddComponentInstance <ILanguageGateway>(new FakeLanguageGateway());

            engine.AddComponentInstance(new DraftRepository(versionRepository, new FakeCacheWrapper()));
        }
示例#3
0
        /// <summary>
        /// Removes the content handler from the subscription asynchronously.
        /// </summary>
        /// <param name="channel">The channel from which unsubscribe.</param>
        /// <param name="contentHandler">The content handler to be removed from this subscription.</param>
        /// <param name="keepUnderlyingSubscription">Indicates if the node should keep the underlying subscription to the channel in order to improve efficiency in future subscriptions to it.</param>
        /// <returns>A task which value is true if the operation succeeded.</returns>
        public virtual Task <bool> Unsubscribe(string channel, ContentHandler contentHandler, bool keepUnderlyingSubscription = false)
        {
            if (!IsConnected)
            {
                throw new NodeDisconnectedException();
            }

            if (string.IsNullOrWhiteSpace(channel))
            {
                throw new ArgumentNullException(nameof(channel));
            }

            if (contentHandler == null)
            {
                throw new ArgumentNullException(nameof(contentHandler));
            }

            channel = channel.ToLower();

            if (_channelsSubscriptions.Remove(contentHandler, channel))
            {
                contentHandler.BeginInvoke(null, new IrisContextHook {
                    Unsubscribing = true
                }, null, null);

                // If there aren't any subscriptions and there's no request of keeping the underlying subscription
                if (!_channelsSubscriptions.GetSubscriptions(channel, true).Any() && !keepUnderlyingSubscription)
                {
                    return(Publish(new IrisUnsubscribe(Id, channel)));
                }
            }

            return(_completedFailedTask);
        }
示例#4
0
    public override void OnLoaded(ContentHandler contentHandler)
    {
        _canvas = RoR2.RoR2Application.instance.mainCanvas;
        var scaler = _canvas.GetComponent <CanvasScaler>();

        scaler.scaleFactor = 1.0f;
        scaler.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;

        var colorPicker = Instantiate(contentHandler.prefabs.Where(p => p.name == "ColorPicker").First());

        Object.DontDestroyOnLoad(colorPicker);
        ColorPicker.Instance = colorPicker.GetComponent <ColorPicker>();
        ColorPicker.Instance.Close();

        var objPicker = Instantiate(contentHandler.prefabs.Where(p => p.name == "ObjectReferencePicker").First());

        Object.DontDestroyOnLoad(objPicker);
        ObjectReferencePicker.Instance = objPicker.GetComponent <ObjectReferencePicker>();
        ObjectReferencePicker.Instance.Close();

        transform.SetParent(_canvas.transform);
        var rect = transform as RectTransform;

        rect.SetSpreadAnchor();
        rect.offsetMin  = Vector2.zero;
        rect.offsetMax  = Vector2.one;
        rect.localScale = Vector3.one;
    }
示例#5
0
 protected CommandButton(ICommand command, IQueueable <TextureValue> queueableObject, Point Size)
 {
     this.bounds   = new Rectangle(queueableObject.Position.ToPoint(), Size);
     this.Position = queueableObject.Position;
     this.picture  = ContentHandler.DrawnTexture(queueableObject.Icon);
     this.command  = command;
 }
示例#6
0
        public override void OnLoaded(ContentHandler contentHandler)
        {
            RuntimeInspectorStartup.AddListener((sender, evt) => {
                var ris = sender as RuntimeInspectorStartup;

                var tpContainer = ris.transform.Find("Container/Menu/Third-party Group");
                if (tpContainer)
                {
                    transform.SetParent(tpContainer.transform);
                }
                else
                {
                    Debug.LogError("Couldn't find RuntimeInspector UI Third-party Group!");
                }

                var uiContainer = ris.transform.Find("Container");
                if (uiContainer)
                {
                    uiContainer.SetParent(RoR2.RoR2Application.instance.mainCanvas.transform);
                    uiContainer.SetAsLastSibling();
                }
                else
                {
                    Debug.LogError("Couldn't find RuntimeInspector UI Container!");
                }
                hierarchy = ris.Hierarchy;
                inspector = ris.Inspector;
                ((RuntimeInspectorStartup)sender).Hierarchy.OnSelectionChanged += Pinger.SetPing;
            });
        }
示例#7
0
        public async Task ShouldGetExpectedContentFromUrlAsync(string content, HttpStatusCode code)
        {
            // arrange
            var url = "http://tdp-itplayground.info/assets/kmlsamples/kmlcontent.xml";

            var response = new HttpResponseMessage(code)
            {
                Content = new StringContent(content)
            };

            var fakeHttpMessageHandler = new FakeHttpMessageHandler(response);

            var fakeHttpClient = new HttpClient(fakeHttpMessageHandler);

            _contentHandler = new ContentHandler(fakeHttpClient);


            // act
            var expectedResponse = await _contentHandler.GetContentFromUrlAsync(url);


            // assert
            response.Content.Should().Be(expectedResponse.Content);
            response.StatusCode.Should().Be(expectedResponse.StatusCode);
        }
 public BasicCore(Game1 game)
 {
     this.game = game;
     this.screen = new Screen();
     this.content = new ContentHandler(this.game.Content);
     this.r = new Registry();
 }
        public void Change()
        {
            Context context = new Context(CurrentUser);

            if (context.ChackValidation())
            {
                try
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Information is clicked.");
                    if (Channel.Instance.userProxy.Update(CurrentUser))
                    {
                        Window.Close();
                    }
                    else
                    {
                        MessageBox.Show("Falied");
                    }
                }
                catch
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                    MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Please, fiil all fields!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ContentHandler.Refresh();
        }
        public void SetDefaultCulture()
        {
            var container = new CultureContentContainer();
            var sut       = new ContentHandler(container);

            //set a couple of cultures
            sut.AddCultureContents(new Dictionary <CultureInfo, ICultureContent> {
                { new CultureInfo("nl-NL"), null },
                { new CultureInfo("ru-KZ"), null },
                { new CultureInfo("en-GB"), null }
            });

            //make sure it is something else before setting
            var cultureInfo = sut.GetDefaultCulture();

            Assert.Equal("nl", cultureInfo.TwoLetterISOLanguageName);
            Assert.Equal("Dutch (Netherlands)", cultureInfo.DisplayName);
            Assert.Equal("nl-NL", cultureInfo.Name);

            sut.SetDefaultCulture(new CultureInfo("ru-KZ"));
            cultureInfo = sut.GetDefaultCulture();
            Assert.Equal("ru", cultureInfo.TwoLetterISOLanguageName);
            Assert.Equal("русский (Казахстан)", cultureInfo.DisplayName);
            Assert.Equal("ru-KZ", cultureInfo.Name);
        }
示例#11
0
    public override void OnLoaded(ContentHandler contentHandler)
    {
        Debug.Log("Hello World!!???");

        // unlock all the things
        On.RoR2.UserProfile.HasSurvivorUnlocked         += (o, s, i) => true;
        On.RoR2.UserProfile.HasDiscoveredPickup         += (o, s, i) => true;
        On.RoR2.UserProfile.HasAchievement              += (o, s, i) => true;
        On.RoR2.UserProfile.CanSeeAchievement           += (o, s, i) => true;
        On.RoR2.UserProfile.HasUnlockable_UnlockableDef += (o, s, i) => true;

        // get reference to game's main canvas
        var canvas = RoR2.RoR2Application.instance.mainCanvas;

        // instantiate UI prefab
        var gobj = Instantiate(prefab);

        gobj.transform.SetParent(canvas.transform, false);

        // set the parent to game's canvas and fix the sizings
        var rect = gobj.GetComponent <RectTransform>();

        rect.offsetMin = rect.offsetMax = Vector2.zero;
        rect.anchorMin = new Vector2(0.00f, 0.00f);
        rect.anchorMax = new Vector2(1.00f, 1.00f);
    }
示例#12
0
 public IrisDisposableSubscription(IIrisNode irisNode, string channel, ContentHandler contentHandler)
 {
     _irisNode      = irisNode;
     Channel        = channel;
     ContentHandler = contentHandler;
     IsDisposed     = false;
 }
        public void GetDefaultCultureEmpty()
        {
            var container = new CultureContentContainer();
            var sut       = new ContentHandler(container);

            Assert.Throws <IndexOutOfRangeException>(() => sut.GetDefaultCulture());
        }
        public void AddShop()
        {
            Context context = new Context(NewShop);

            if (!context.ChackValidation())
            {
                return;
            }
            logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, CurrentUser.Name + " has clicked add Shop.");
            try
            {
                if (Channel.Instance.shopProxy.AddShop(NewShop))
                {
                    Window.Close();
                }
                else
                {
                    MessageBox.Show("Shop already exists");
                }
            }
            catch
            {
                logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ContentHandler.Refresh();
        }
示例#15
0
        /// <exception cref="Org.Xml.Sax.SAXException"/>
        public static void WriteCachePoolInfo(ContentHandler contentHandler, CachePoolInfo
                                              info)
        {
            XMLUtils.AddSaxString(contentHandler, "POOLNAME", info.GetPoolName());
            string       ownerName         = info.GetOwnerName();
            string       groupName         = info.GetGroupName();
            long         limit             = info.GetLimit();
            FsPermission mode              = info.GetMode();
            long         maxRelativeExpiry = info.GetMaxRelativeExpiryMs();

            if (ownerName != null)
            {
                XMLUtils.AddSaxString(contentHandler, "OWNERNAME", ownerName);
            }
            if (groupName != null)
            {
                XMLUtils.AddSaxString(contentHandler, "GROUPNAME", groupName);
            }
            if (mode != null)
            {
                FSEditLogOp.FsPermissionToXml(contentHandler, mode);
            }
            if (limit != null)
            {
                XMLUtils.AddSaxString(contentHandler, "LIMIT", System.Convert.ToString(limit));
            }
            if (maxRelativeExpiry != null)
            {
                XMLUtils.AddSaxString(contentHandler, "MAXRELATIVEEXPIRY", System.Convert.ToString
                                          (maxRelativeExpiry));
            }
        }
示例#16
0
 /// <exception cref="Org.Xml.Sax.SAXException"/>
 public static void WriteCacheDirectiveInfo(ContentHandler contentHandler, CacheDirectiveInfo
                                            directive)
 {
     XMLUtils.AddSaxString(contentHandler, "ID", System.Convert.ToString(directive.GetId
                                                                             ()));
     if (directive.GetPath() != null)
     {
         XMLUtils.AddSaxString(contentHandler, "PATH", directive.GetPath().ToUri().GetPath
                                   ());
     }
     if (directive.GetReplication() != null)
     {
         XMLUtils.AddSaxString(contentHandler, "REPLICATION", short.ToString(directive.GetReplication
                                                                                 ()));
     }
     if (directive.GetPool() != null)
     {
         XMLUtils.AddSaxString(contentHandler, "POOL", directive.GetPool());
     }
     if (directive.GetExpiration() != null)
     {
         XMLUtils.AddSaxString(contentHandler, "EXPIRATION", string.Empty + directive.GetExpiration
                                   ().GetMillis());
     }
 }
示例#17
0
        private static void InitializeModSurrogate()
        {
            List <GameObject> prefabs = new List <GameObject>();
            List <IResource>  scenes  = new List <IResource>();

            List <string> prefabPaths = AssetUtility.GetAssets("t:prefab");

            foreach (string prefabPath in prefabPaths)
            {
                prefabs.Add(AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath));
            }

            List <string> scenePaths = AssetUtility.GetAssets("t:scene");

            foreach (string scenePath in scenePaths)
            {
                string sceneName = Path.GetFileNameWithoutExtension(scenePath);
                scenes.Add(new ModSceneSurrogate(sceneName));
            }

            ModSurrogate mod = new ModSurrogate(ExportSettings.name);

            ContentHandler contentHandler = new ContentHandler(mod, scenes.AsReadOnly(), prefabs.AsReadOnly());

            InitializeModHandlers(contentHandler);
        }
 public BasicCore(Game1 game)
 {
     this.game    = game;
     this.screen  = new Screen();
     this.content = new ContentHandler(this.game.Content);
     this.r       = new Registry();
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            kinectRGBVideo = new Texture2D(GraphicsDevice, 1337, 1337);
            this.ch        = new ContentHandler(Content);

            this.ch.add("joint", "joint");
            this.ch.add("bone", "bone");
            this.ch.add("defaultFont", "SpriteFont1");

            // Botones de Jose
            this.ch.add("PLAY", "play");
            this.ch.add("EXIT", "exit");
            this.ch.add("MENU", "menu");
            this.ch.add("REPLAY", "replay");
            this.ch.add("NEXT", "next");
            this.ch.add("PAUSE", "pause");
            this.ch.add("CONTINUE", "continue");

            // Este load al final
            this.ch.load();
            this.gameCore.loadContentHandler(ch);
            this.gameCore.gameScreen.updateSpriteBatch(new SpriteBatch(GraphicsDevice));

            this.gameCore.loadKinectSensor(kinectSensor);
        }
示例#20
0
        public void Parse(InputSource input)
        {
            var document = new HtmlDocument();

            if (input.Stream != null)
            {
                document.Load(input.Stream, input.Encoding);
            }
            else if (input.Reader != null)
            {
                document.Load(input.Reader);
            }
            else if (input.PublicId != null)
            {
                document.Load(input.PublicId);
            }
            else if (input.SystemId != null)
            {
                document.Load(input.SystemId);
            }

            ContentHandler.StartDocument();

            TraverseNode(document.DocumentNode);

            ContentHandler.EndDocument();
        }
        public MainWindowViewModel()
        {
            #region starting view content
            logHandler = LogHandler.Instance;
            logHandler.MainWindowViewModel = this;
            ContentHandler.StartContent();
            Refresh();
            #endregion

            #region Commands
            AddUserCommand            = new AddUserCommand(this);
            ViewProfilInfoCommand     = new ViewProfilInfoCommand(this);
            AddTelephoneCommand       = new AddTelephoneCommand(this);
            AddShopCommand            = new AddShopCommand(this);
            ChangeTelephoneCommand    = new ChangeTelephoneInfoCommand(this);
            DeleteTelephoneCommand    = new DeleteTelephoneCommand(this);
            DuplicateTelephoneCommand = new DuplicateTelephoneCommand(this);
            ChangeShopCommand         = new ChangeShopInfoCommand(this);
            DeleteShopCommand         = new DeleteShopCommand(this);
            LogOutCommand             = new LogOutCommand(this);
            BuyTelephoneCommand       = new BuyTelephoneCommand(this);
            ClearCommand   = new ClearCommand(this);
            UndoCommand    = new UndoCommand(this);
            RedoCommand    = new RedoCommand(this);
            FilterCommand  = new FilterCommand(this);
            RefreshCommand = new RefreshCommand(this);
            #endregion
        }
示例#22
0
        private void TraverseNode(HtmlNode htmlNode)
        {
            if (htmlNode == null || htmlNode.NodeType == HtmlNodeType.Comment)
            {
                return;
            }

            var attributes = new Attributes();

            if (htmlNode.HasAttributes)
            {
                foreach (HtmlAttribute attribute in htmlNode.Attributes)
                {
                    attributes.AddAttribute(null, htmlNode.Name, attribute.Name, null, attribute.Value);
                }
            }

            ContentHandler.StartElement(null, htmlNode.Name, htmlNode.Name, attributes);
            if (htmlNode.NodeType == HtmlNodeType.Text)
            {
                ContentHandler.Characters(htmlNode.InnerText.ToCharArray(), 0, htmlNode.InnerText.Length);
            }
            else if (htmlNode.HasChildNodes)
            {
                foreach (HtmlNode childNode in htmlNode.ChildNodes)
                {
                    TraverseNode(childNode);
                }
            }
            ContentHandler.EndElement(null, htmlNode.Name, htmlNode.Name);
        }
示例#23
0
        public static ClientList LoadClients(string file)
        {
            ClientList cl = ContentHandler.Load <ClientList>(file);

            cl.CreateDict();
            return(cl);
        }
示例#24
0
        public Indexer(Analyzer contentAnalyzer, Analyzer queryAnalyzer, IJobAdSearchBooster booster, ILocationQuery locationQuery, IIndustriesQuery industriesQuery, IJobAdFlagListsQuery jobAdFlagListsQuery)
        {
            _contentAnalyzer = contentAnalyzer;
            _queryBuilder    = new QueryBuilder(queryAnalyzer, booster);

            _contentHandler     = new ContentHandler(booster);
            _locationHandler    = new LocationContentHandler(booster, locationQuery);
            _industryHandler    = new IndustryContentHandler(booster, industriesQuery);
            _salaryHandler      = new SalaryContentHandler(booster);
            _jobTypesHandler    = new JobTypesContentHandler(booster);
            _createdTimeHandler = new CreatedTimeContentHandler(booster);
            _communityHandler   = new CommunityContentHandler(booster);
            _featuredHandler    = new FeaturedContentHandler(booster);

            _handlers = new[]
            {
                _locationHandler,
                _salaryHandler,
                _industryHandler,
                _jobTypesHandler,
                _createdTimeHandler,
                _communityHandler,
                _featuredHandler
            };

            _jobAdFlagListsQuery = jobAdFlagListsQuery;
        }
    private void Start()
    {
        m_contentUI     = GetComponentInChildren <ContentHandler>();
        m_rectTransform = GetComponent <RectTransform>();

        m_widthRect = m_rectTransform.rect.width;
    }
示例#26
0
文件: Tooltip.cs 项目: Zedfa/Core
 private void SerializeContent(Dictionary <string, object> options)
 {
     if (ContentUrl.HasValue())
     {
         options["content"] = new Dictionary <string, object>()
         {
             { "url", ContentUrl }
         };
     }
     else if (ContentHandler.HasValue())
     {
         options["content"] = ContentHandler;
     }
     else if (!String.IsNullOrEmpty(ContentTemplateId))
     {
         var idPrefix = "#";
         if (IsInClientTemplate)
         {
             idPrefix = "\\" + idPrefix;
         }
         options["content"] = new ClientHandlerDescriptor {
             HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, ContentTemplateId)
         };
     }
     else if (Content.HasValue())
     {
         options["content"] = HttpUtility.UrlDecode(Content);
     }
 }
示例#27
0
 public void LogIn()
 {
     try
     {
         Channel.Instance.logProxy.LogMessage(Enums.LOGTYPE.INFO, "Log In is clicked.");
         User user = Channel.Instance.userProxy.Get(UserName);
         if (user != null)
         {
             if (user.Password == Password)
             {
                 new MainWindow(user).Show();
                 Window.Close();
             }
             else
             {
                 MessageBox.Show("Password is incorect!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         else
         {
             MessageBox.Show("User does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch
     {
         MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     ContentHandler.StartContent();
 }
 public void ChangeShop()
 {
     if (CanChange)
     {
         try
         {
             logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Shop is clicked.");
             if (Channel.Instance.shopProxy.UpdateShop(CurrentShop))
             {
                 Window.Close();
             }
             else
             {
                 MessageBox.Show("Name is already exists!");
             }
         }
         catch
         {
             logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
         }
     }
     else
     {
         MessageBox.Show("Fields cannot be empty! Please, fill them.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     ContentHandler.Refresh();
 }
示例#29
0
 protected CommandButton(ICommand command, Vector2 position, TextureValue picture, Point size) : base(position, size, Color.White)
 {
     this.bounds   = new Rectangle(position.ToPoint(), Size);
     this.Position = position;
     this.picture  = ContentHandler.DrawnTexture(picture);
     this.command  = command;
     this.Size     = size;
 }
示例#30
0
        public void ContentHandlerJsonObjectNullTest()
        {
            var h   = new ContentHandler();
            var obj = h.ObjectFrom("{\"a\":null}");

            Assert.AreEqual("JSON Object", obj.ToString());
            Assert.IsNull(obj.GetProperty("a"));
        }
示例#31
0
        // public List<GameObject> adjust_button;

        public override void OnLoaded(ContentHandler contentHandler)
        {
            Debug.Log("------ Item Exchange Initiated ------");

            InvData  = new List <ItemData>();
            TileList = new List <GameObject>();
            InitUI();
        }
示例#32
0
        public override void parse(java.io.InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
        {
            metadata.set(Metadata.TYPE, XPS_MIME_TYPE);

            try
            {
                var getFile = stream.getClass().getMethod("getFile");
                var file = getFile.invoke(stream);
                var path = file.ToString();

                var xhtml = new XHTMLContentHandler(handler, metadata);
                xhtml.startDocument();

                using (var xpsDocument = new XpsDocument(path, FileAccess.Read))
                {
                    var fixedDocSeqReader = xpsDocument.FixedDocumentSequenceReader;
                    if (fixedDocSeqReader == null)
                        return;

                    foreach (var document in fixedDocSeqReader.FixedDocuments)
                    {
                        var page = document.FixedPages[0];
                        using (var pageContentReader = page.XmlReader)
                        {
                            parsePage(xhtml, pageContentReader);
                        }
                    }
                }

                xhtml.endDocument();
            }
            catch (Exception e)
            {
                throw new java.io.IOException(e);
            }
        }
 public Boolean Initialize()
 {
     this.content = new ContentHandler(this.game.Content);
     return onInitialize();
 }
示例#34
0
        /// <summary>
        /// Initialize our Game Data
        /// </summary>
        protected override void Initialize()
        {
            ContentHandler = new ContentHandler(this, Services, "Content");

            Components.Add(new InputHandler(this));
            Components.Add(ContentHandler);
            Components.Add(new ScreenHandler(this));

            Content = ContentHandler.Content;
            GraphicsHandler.Initialize(this);

            ActionHandler.Load();

            base.Initialize();
        }
 public void loadContentHandler(ContentHandler ch)
 {
     this.ch = ch;
     gameScreen.updateContentHandler(ch);
 }
示例#36
0
        public void Parse(StreamReader input, ContentHandler handler) {
            var buffer = new StringBuilder();

            var isInsideTag = false;
            var isStartTag = true;

            var lastChar = -1;
            int c;
            while ((c = input.Read()) != -1) {
                if ('<' == c) {
                    if (isInsideTag) {
                        throw new InvalidFormatException("Did not expect < char!");
                    }

                    if (buffer.ToString().Trim().Length > 0) {
                        handler.Characters(buffer.ToString().Trim());
                    }

                    buffer = new StringBuilder();

                    isInsideTag = true;
                    isStartTag = true;
                }

                // buffer.AppendCodePoint(c); <-- java
                buffer.Append(char.ConvertFromUtf32(c));


                if ('/' == c && lastChar == '<') {
                    isStartTag = false;
                }

                if ('>' == c) {
                    if (!isInsideTag) {
                        throw new InvalidFormatException("Did not expect > char!");
                    }

                    if (isStartTag) {
                        handler.StartElement(extractTagName(buffer), getAttributes(buffer));
                    } else {
                        handler.EndElement(extractTagName(buffer));
                    }

                    buffer = new StringBuilder();

                    isInsideTag = false;
                }

                lastChar = c;
            }

            if (isInsideTag) {
                throw new InvalidFormatException("Did not find matching > char!");
            }
        }
示例#37
0
 /**
  * Set the content handler.
  *
  * @param handler the new content handler
  * @see org.xml.sax.XMLReader#setEntityResolver
  */
 public void setContentHandler(ContentHandler handler)
 {
     contentHandler = handler;
 }
示例#38
0
 /**
  * Sets the {@link ContentHandler} which receives
  * the augmented validation result.
  *
  * <p/>
  * When a {@link ContentHandler} is specified, a
  * {@link ValidatorHandler} will work as a filter
  * and basically copy the incoming events to the
  * specified {@link ContentHandler}.
  *
  * <p/>
  * In doing so, a {@link ValidatorHandler} may modify
  * the events, for example by adding defaulted attributes.
  *
  * <p/>
  * A {@link ValidatorHandler} may buffer events to certain
  * extent, but to allow {@link ValidatorHandler} to be used
  * by a parser, the following requirement has to be met.
  *
  * <ol>
  *  <li>When
  *      {@link ContentHandler#startElement(String, String, String, Attributes)},
  *      {@link ContentHandler#endElement(String, String, String)},
  *      {@link ContentHandler#startDocument()}, or
  *      {@link ContentHandler#endDocument()}
  *      are invoked on a {@link ValidatorHandler},
  *      the same method on the user-specified {@link ContentHandler}
  *      must be invoked for the same event before the callback
  *      returns.</li>
  *  <li>{@link ValidatorHandler} may not introduce new elements that
  *      were not present in the input.</li>
  *
  *  <li>{@link ValidatorHandler} may not remove attributes that were
  *      present in the input.</li>
  * </ol>
  *
  * <p/>
  * When a callback method on the specified {@link ContentHandler}
  * throws an exception, the same exception object must be thrown
  * from the {@link ValidatorHandler}. The {@link ErrorHandler}
  * should not be notified of such an exception.
  *
  * <p/>
  * This method can be called even during a middle of a validation.
  *
  * @param receiver
  *      A {@link ContentHandler} or a null value.
  */
 public abstract void setContentHandler(ContentHandler receiver);