本文整理汇总了C#中Blob.ToObjectURL方法的典型用法代码示例。如果您正苦于以下问题:C# Blob.ToObjectURL方法的具体用法?C# Blob.ToObjectURL怎么用?C# Blob.ToObjectURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob.ToObjectURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
//.........这里部分代码省略.........
// extension unloaded
Native.body.style.borderTop = "0em solid red";
Native.body.style.borderLeft = "0em solid red";
forms.WithEach(f => f.Close());
}
)
);
e.onMessage.addListener(
new Action<dynamic>(
data =>
{
string xml = data.xml;
if (xml != null)
{
// tab injection was notified by extension, by app, by udp android?
Native.body.style.borderLeft = "1em solid red";
// 0:40394ms { xml = <string c="1">Visit me at 192.168.1.67:6169</string> }
Console.WriteLine(new { xml });
// X:\jsc.internal.git\market\chrome\ChromeMyJscSolutionsNet\ChromeMyJscSolutionsNet\Application.cs
onxmlmessage(
XElement.Parse(xml)
);
}
string code = data.code;
if (code != null)
{
//Console.WriteLine("webview: onMessage " + new { data });
// %c0:41906ms extension: onMessage { data = connected! }
//e.postMessage("got code! " + new { code.Length });
Native.body.style.borderTop = "1em solid red";
// InternalInlineWorker
// http://stackoverflow.com/questions/21408510/chrome-cant-load-web-worker
// this wont work for file:// tabs
// message: "Failed to construct 'Worker': Script at 'blob:null/f544915f-b855-480b-8db8-bd6c686829b9#worker' cannot be accessed from origin 'null'."
var aFileParts = new[] { code };
var oMyBlob = new Blob(aFileParts, new { type = "text/javascript" }); // the blob
var url = oMyBlob.ToObjectURL();
InternalInlineWorker.ScriptApplicationSourceForInlineWorker = url;
Notify = x =>
{
// Error in event handler for (unknown): Attempting to use a disconnected port object Stack trace: Error: Attempting to use a disconnected port object
e.postMessage(x);
};
}
}
)
);
};
//chrome.runtime.Message +=
// delegate
// {
// Console.WriteLine("chrome.runtime.Message");
// };
}
#endregion
// 0:168ms chrome.runtime.Connect
// https://developer.chrome.com/extensions/tabs#method-sendMessage
// chrome extension wont call here?
//Native.window.onmessage +=
// e =>
// {
// Console.WriteLine(
// "onmessage: " +
// new { e.data }
// );
// e.postMessage("ok");
// };
}
示例2: eval
public static Action eval(this InternalScriptApplicationSource e)
{
Console.WriteLine("eval total " + new { e.source.Length });
var blob = new Blob(new[] { e.source });
var src = blob.ToObjectURL();
Console.WriteLine(new { src });
//eval total { Length = 2375680 }
// view-source:27603
//ToObjectURL
// view-source:27603
//eval { index = 2, name = ScriptCoreLib.Windows.Forms.dll.js, size = 595965 }
// view-source:27603
//eval { index = 0, name = ScriptCoreLib.dll.js, size = 1338946 }
// view-source:27603
//eval { index = 1, name = ScriptCoreLib.Drawing.dll.js, size = 54667 }
// view-source:27603
//eval { index = 3, name = com.abstractatech.adminshell.Application+a.exe.js, size = 457444 }
// view-source:27603
//eval substring { Length = 1036734 }
//.SetInternalScriptApplicationSource();
object old = (Native.self as dynamic).InternalScriptApplicationSource;
(Native.self as dynamic).InternalScriptApplicationSource = src;
var core = e.references.First(k => k.index == 0).size;
// eval { index = 2, name = ScriptCoreLib.Windows.Forms.dll.js, size = 586774 }
// view-source:27522
//eval { index = 0, name = ScriptCoreLib.dll.js, size = 1325900 }
// view-source:27522
//eval { index = 1, name = ScriptCoreLib.Drawing.dll.js, size = 54215 }
// view-source:27522
//eval { index = 3, name = com.abstractatech.adminshell.Application+a.exe.js, size = 384908 }
// view-source:27522
//eval { core = 586774, Length = 2351797 }
e.references.WithEach(
k =>
Console.WriteLine("eval " + new { k.index, k.name, k.size })
);
// eval { Length = 0 }
var source = e.source.Substring(
core
);
Console.WriteLine("eval substring " + new { source.Length });
//Console.WriteLine(source);
//Native.window.eval(e.source);
Native.window.eval(source);
return delegate
{
// hacky way to restore
if (old != null)
(Native.self as dynamic).InternalScriptApplicationSource = old;
else
(Native.self as dynamic).InternalScriptApplicationSource = Native.document.location + "view-source";
};
}