本文整理汇总了C#中Microsoft.JScript.Vsa.VsaEngine.InitNew方法的典型用法代码示例。如果您正苦于以下问题:C# VsaEngine.InitNew方法的具体用法?C# VsaEngine.InitNew怎么用?C# VsaEngine.InitNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.Vsa.VsaEngine
的用法示例。
在下文中一共展示了VsaEngine.InitNew方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEngineClosed
public void OnEngineClosed ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
engine.Close ();
int size;
try {
size = items.Count;
} catch (VsaException e) {
Assert.AreEqual (VsaError.EngineClosed, e.ErrorCode, "#1");
}
try {
item = items.CreateItem ("itemx", VsaItemType.Code,
VsaItemFlag.Class);
} catch (VsaException e) {
Assert.AreEqual (VsaError.EngineClosed, e.ErrorCode, "#2");
}
}
示例2: JScriptEngine
public JScriptEngine(object scriptGlobal)
: base(scriptGlobal)
{
engine = new Microsoft.JScript.Vsa.VsaEngine();
engine.RootMoniker = "sharpvectors://jsengine/" + counter++;
engine.Site = this;
engine.InitNew();
engine.RootNamespace = "SharpVectors.Scripting";
engine.GenerateDebugInfo = false;
engine.RevokeCache();
engine.SetOption("Fast", false);
items = engine.Items;
Assembly asm = typeof(SharpVectors.Scripting.JScriptEngine).Assembly;
IVsaReferenceItem refItem = (IVsaReferenceItem)items.CreateItem(asm.Location, VsaItemType.Reference, VsaItemFlag.None);
refItem.AssemblyName = asm.Location;
}
示例3: OnItemNotFound
public void OnItemNotFound ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
try {
item = items [-1];
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#3");
}
try {
item = items [20];
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#4");
}
try {
item = items ["IamNotHere"];
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#5");
}
try {
items.Remove (20);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#6");
}
try {
items.Remove (-1);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#7");
}
}
示例4: IsDirtyOnCreateItem
public void IsDirtyOnCreateItem ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine.RootMoniker = "foo://nowhere/path";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
item = items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
Assert.AreEqual (true,item.IsDirty, "#2");
item = items.CreateItem ("item2", VsaItemType.AppGlobal, VsaItemFlag.None);
Assert.AreEqual (true, item.IsDirty, "#3");
item = items.CreateItem ("item3", VsaItemType.Code, VsaItemFlag.Module);
Assert.AreEqual (true, item.IsDirty, "#4");
}
示例5: IsDirtyOnEngineClosed
public void IsDirtyOnEngineClosed ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine.RootMoniker = "foo://nowhere/path";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
item = items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
engine.Close ();
try {
bool dirty = item.IsDirty;
} catch (VsaException e) {
Assert.AreEqual (VsaError.EngineClosed, e.ErrorCode, "#1");
}
}
示例6: CreateItemOnRepeatedName
public void CreateItemOnRepeatedName ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
items.CreateItem ("item2", VsaItemType.AppGlobal, VsaItemFlag.None);
try {
items.CreateItem ("item2",
VsaItemType.Reference,
VsaItemFlag.None);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNameInUse, e.ErrorCode, "#20");
}
}
示例7: Retrieve
public void Retrieve ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
items.CreateItem ("item2", VsaItemType.AppGlobal, VsaItemFlag.None);
items.CreateItem ("item3", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item4", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item5", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item6", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item7", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item8", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item9", VsaItemType.Code, VsaItemFlag.Module);
items.CreateItem ("item10", VsaItemType.Code, VsaItemFlag.Module);
item = items [2];
Assert.AreEqual ("item3", item.Name, "#16");
items.Remove ("item6");
Assert.AreEqual ("item7", items [5].Name, "#17");
try {
items.Remove ("itemNonExistent");
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#18");
}
items.Remove (3);
Assert.AreEqual ("item5", items [3].Name, "#19");
}
示例8: Remove
public void Remove ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
items.CreateItem ("item2", VsaItemType.AppGlobal, VsaItemFlag.None);
items.CreateItem ("item3", VsaItemType.Code, VsaItemFlag.Module);
Assert.AreEqual (3, items.Count, "#12");
try {
item = items [4];
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#13");
}
string ERASED_ITEM = "item2";
items.Remove (ERASED_ITEM);
Assert.AreEqual (2, items.Count, "#14");
try {
item = items [ERASED_ITEM];
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemNotFound, e.ErrorCode, "#15");
}
}
示例9: OnItemFlagNotSupported
public void OnItemFlagNotSupported ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine = new VsaEngine ();
engine.RootMoniker = "com.foo://path/to/nowhere";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
try {
item = items.CreateItem ("item1",
VsaItemType.Reference,
VsaItemFlag.Class);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemFlagNotSupported, e.ErrorCode, "#8");
}
try {
item = items.CreateItem ("item2",
VsaItemType.Reference,
VsaItemFlag.Module);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemFlagNotSupported, e.ErrorCode, "#9");
}
try {
item = items.CreateItem ("item3",
VsaItemType.AppGlobal,
VsaItemFlag.Class);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemFlagNotSupported, e.ErrorCode, "#10");
}
try {
item = items.CreateItem ("item4",
VsaItemType.AppGlobal,
VsaItemFlag.Module);
} catch (VsaException e) {
Assert.AreEqual (VsaError.ItemFlagNotSupported, e.ErrorCode, "#11");
}
}
示例10: GetOptionOnEngineClosed
public void GetOptionOnEngineClosed ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine.RootMoniker = "foo://nowhere/path";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
item = items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
engine.Close ();
try {
object opt = item.GetOption ("AlwaysGenerateIL");
} catch (VsaException e) {
Assert.AreEqual (VsaError.EngineClosed, e.ErrorCode, "#6");
}
}
示例11: SetOptionOnOptionNotSupported
public void SetOptionOnOptionNotSupported ()
{
VsaEngine engine = new VsaEngine ();
IVsaItems items;
IVsaItem item;
engine.RootMoniker = "foo://nowhere/path";
engine.Site = new Site ();
engine.InitNew ();
items = engine.Items;
item = items.CreateItem ("item1", VsaItemType.Reference, VsaItemFlag.None);
try {
item.SetOption ("OptionNotSupportedByThisScriptingEngine", true);
} catch (VsaException e) {
Assert.AreEqual (VsaError.OptionNotSupported, e.ErrorCode, "#9");
}
}